Skip to content

Commit

Permalink
fixup! feat: Use inline password confirmation in external storage set…
Browse files Browse the repository at this point in the history
…tings
  • Loading branch information
artonge committed Nov 28, 2024
1 parent d6fdeff commit c66d515
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,37 @@ public function beforeController(Controller $controller, string $methodName) {
}
}

$backendClassName = $user->getBackendClassName();

try {
$sessionId = $this->session->getId();
$token = $this->tokenProvider->getToken($sessionId);
} catch (SessionNotAvailableException|InvalidTokenException|WipeTokenException|ExpiredTokenException) {
// States we do not deal with here.
return;
}

$scope = $token->getScopeAsArray();
if (isset($scope['password-unconfirmable']) && $scope['password-unconfirmable'] === true) {
// Users logging in from SSO backends cannot confirm their password by design
return;
}

$lastConfirm = (int) $this->session->get('last-password-confirm');
// TODO: confirm excludedUserBackEnds can go away and remove it
if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
throw new NotConfirmedException();
if ($this->isPasswordConfirmationStrict($reflectionMethod)) {
$authHeader = $this->request->getHeader('Authorization');
[, $password] = explode(':', base64_decode(substr($authHeader, 6)), 2);
$loginResult = $this->userManager->checkPassword($user->getUid(), $password);
if ($loginResult === false) {
throw new NotConfirmedException();
}

$this->session->set('last-password-confirm', $this->timeFactory->getTime());
} else {
$lastConfirm = (int) $this->session->get('last-password-confirm');
// TODO: confirm excludedUserBackEnds can go away and remove it
if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
throw new NotConfirmedException();
}
}
}
}
Expand Down

0 comments on commit c66d515

Please sign in to comment.