dont create a session token for clients, validate the app password instead
This commit is contained in:
parent
0c0a216f42
commit
1889df5c7c
|
@ -197,14 +197,27 @@ class Session implements IUserSession, Emitter {
|
||||||
return $this->activeUser;
|
return $this->activeUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate whether the current session is valid
|
||||||
|
*
|
||||||
|
* - For token-authenticated clients, the token validity is checked
|
||||||
|
* - For browsers, the session token validity is checked
|
||||||
|
*/
|
||||||
protected function validateSession() {
|
protected function validateSession() {
|
||||||
try {
|
$token = null;
|
||||||
$sessionId = $this->session->getId();
|
$appPassword = $this->session->get('app_password');
|
||||||
} catch (SessionNotAvailableException $ex) {
|
|
||||||
return;
|
if (is_null($appPassword)) {
|
||||||
|
try {
|
||||||
|
$token = $this->session->getId();
|
||||||
|
} catch (SessionNotAvailableException $ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$token = $appPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->validateToken($sessionId)) {
|
if (!$this->validateToken($token)) {
|
||||||
// Session was invalidated
|
// Session was invalidated
|
||||||
$this->logout();
|
$this->logout();
|
||||||
}
|
}
|
||||||
|
@ -282,7 +295,6 @@ class Session implements IUserSession, Emitter {
|
||||||
|
|
||||||
$this->loginWithToken($password);
|
$this->loginWithToken($password);
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$this->tokenProvider->updateTokenActivity($token);
|
|
||||||
} else {
|
} else {
|
||||||
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
|
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
|
||||||
$user = $this->manager->checkPassword($uid, $password);
|
$user = $this->manager->checkPassword($uid, $password);
|
||||||
|
@ -341,7 +353,10 @@ class Session implements IUserSession, Emitter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->supportsCookies($request)) {
|
if ($isTokenPassword) {
|
||||||
|
$this->session->set('app_password', $password);
|
||||||
|
} else if($this->supportsCookies($request)) {
|
||||||
|
// Password login, but cookies supported -> create (browser) session token
|
||||||
$this->createSessionToken($request, $this->getUser()->getUID(), $user, $password);
|
$this->createSessionToken($request, $this->getUser()->getUID(), $user, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +473,6 @@ class Session implements IUserSession, Emitter {
|
||||||
|
|
||||||
//login
|
//login
|
||||||
$this->setUser($user);
|
$this->setUser($user);
|
||||||
$this->tokenProvider->updateTokenActivity($dbToken);
|
|
||||||
|
|
||||||
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
|
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
|
||||||
return true;
|
return true;
|
||||||
|
@ -582,6 +596,8 @@ class Session implements IUserSession, Emitter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->tokenProvider->updateTokenActivity($dbToken);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue