Skip to content

Commit 5c2740e

Browse files
committed
store timestamp into session, not state
1 parent 1075103 commit 5c2740e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Auth/Process/WebAuthn.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ public function process(array &$state): void {
142142
unset($state['Attributes']['internal:FIDO2PasswordlessAuthentication']);
143143
return;
144144
}
145-
145+
$session = Session::getSessionFromRequest();
146+
$lastSecondFactor = $session->getData("DateTime", 'LastSuccessfulSecondFactor');
146147
if // do we need to do secondFactor in interval, or even every time?
147148
// we skip only if an interval is configured AND we did successfully authenticate, AND are within the interval
148149
(
149150
$this->SecondFactorMaxAge >= 0 && //
150151
(
151-
isset($state['Attributes']['LastSuccessfulSecondFactor']) &&
152-
$state['Attributes']['LastSuccessfulSecondFactor'] instanceof \DateTime
152+
$lastSecondFactor instanceof \DateTime
153153
)
154154
) {
155-
$interval = \DateTime::diff($state['Attributes']['LastSuccessfulSecondFactor'], \DateTime());
155+
$interval = \DateTime::diff($lastSecondFactor, \DateTime());
156156
if ($interval->invert == 1) {
157157
throw new \Exception("We are talking to a future self. Amazing.");
158158
}

src/Controller/AuthProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function (WebAuthnAuthenticationEvent $authObject, array $state) {
231231
// take note of the current timestamp so we know
232232
// a) that second-factor was done successfully in the current sesssion
233233
// b) when that event occured, so as to make regular re-auths configurable
234-
$state['Attributes']['LastSuccessfulSecondFactor'] = new \DateTime();
234+
$this->session->setData("DateTime", 'LastSuccessfulSecondFactor', new \DateTime());
235235
$this->authState::saveState($state, 'webauthn:request');
236236
}
237237
if ($state['FIDO2PasswordlessAuthMode'] === true) {

0 commit comments

Comments
 (0)