-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow limiting lifespan of low-aal sessions #1942
base: master
Are you sure you want to change the base?
Conversation
Needs tests but please do an initial review. |
if config.AllowLowAAL != nil && *config.AllowLowAAL != 0 && CompareAAL(ParseAAL(s.AAL), userHighestPossibleAAL) < 0 && now.After(s.CreatedAt.Add(*config.AllowLowAAL)) { | ||
return SessionLowAAL | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit, but a lot here in one line but maybe:
isLowAAL := config.AllowLowAAL != nil && *config.AllowLowAAL != 0
isLowAAL = isLowAAL && CompareAAL(ParseAAL(s.AAL), userHighestPossibleAAL) < 0
isLowAAL = isLowAAL && now.After(s.CreatedAt.Add(*config.AllowLowAAL)
if isLowAAL {
return SessionLowAAL
}
@@ -34,6 +34,30 @@ func (aal AuthenticatorAssuranceLevel) String() string { | |||
} | |||
} | |||
|
|||
// CompareAAL returns 0 if both AAL levels are equal, > 0 if A is a higher level than B or < 0 if A is a lower level than B. | |||
func CompareAAL(a, b AuthenticatorAssuranceLevel) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, b int comparisons like this can be error prone, I think we saw it in the crypto package once. It may be worth adding some helper methods:
func (aal AuthenticatorAssuranceLevel) Above(level AuthenticatorAssuranceLevel) bool
func (aal AuthenticatorAssuranceLevel) Below(level AuthenticatorAssuranceLevel) bool
func (aal AuthenticatorAssuranceLevel) Equal(level AuthenticatorAssuranceLevel) bool
func (aal AuthenticatorAssuranceLevel) Down OR Lower() (level AuthenticatorAssuranceLevel) # To lower a level (can do this instead of (Above() || Equal()) or adding AboveOrEqual() etc.)
func (aal AuthenticatorAssuranceLevel) Up OR Raise() (level AuthenticatorAssuranceLevel) # To raise a level
Pull Request Test Coverage Report for Build 13260664998Details
💛 - Coveralls |
Adds a new optional config
GOTRUE_SESSIONS_ALLOW_LOW_AAL
(duration) which when set will prevent the continued refreshing of a user session if the session has not been upgraded to the highest possible AAL level of the user.For example if you set it to
1h
it means that a user who has MFA factors enrolled must step-up the session to the highest AAL level for their account within 1 hour, otherwise future session refreshes will fail with aInvalid Refresh Token: Session Expired (Low AAL: User Needs MFA Verification)
) message.