Skip to content

Commit e1baf44

Browse files
committed
fix: expire initial jwt based on session creation time
1 parent da20f2a commit e1baf44

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

internal/tokens/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ func (s *Service) GenerateAccessToken(r *http.Request, tx *storage.Connection, p
676676
// if user has mfa enabled and the session has not yet been upgraded
677677
// and Limit duration of AAL1 sessions is enabled
678678
// expiresAt should be set to the maximum duration for low aal sessions
679-
expiresAt = issuedAt.Add(*config.Sessions.AllowLowAAL)
679+
expiresAt = session.CreatedAt.UTC().Add(*config.Sessions.AllowLowAAL)
680680
} else {
681681
expiresAt = issuedAt.Add(time.Second * time.Duration(config.JWT.Exp))
682682
}

internal/tokens/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ func TestGenerateAccessTokenAllowLowAAL(t *testing.T) {
12371237
AuthenticationMethod: models.PasswordGrant,
12381238
})
12391239
require.NoError(t, err)
1240-
require.Equal(t, now.Add(allowLowAAL).Unix(), expiresAt)
1240+
require.Equal(t, session.CreatedAt.UTC().Add(allowLowAAL).Unix(), expiresAt)
12411241
})
12421242

12431243
t.Run("AAL2 session for MFA user uses standard JWT expiry", func(t *testing.T) {

0 commit comments

Comments
 (0)