-
Notifications
You must be signed in to change notification settings - Fork 398
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: add claim to JWT to indicate if there are verified MFA factors for user #1823
base: master
Are you sure you want to change the base?
Conversation
…the JWT consumer (e.g. if JWT is passed to some other API which verifies its authenticity) can only enforce 2FA AAL levels once 2FA is enabled. This allows to enforce 2FA only when at least one factor is used making 2FA roll-out optional.
aal2
only if 2FA is enabled on user's account
Pull Request Test Coverage Report for Build 11589790641Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@@ -309,6 +309,15 @@ func (a *API) generateAccessToken(r *http.Request, tx *storage.Connection, user | |||
issuedAt := time.Now().UTC() | |||
expiresAt := issuedAt.Add(time.Second * time.Duration(config.JWT.Exp)).Unix() | |||
|
|||
atLeastOneVerifiedFactor := false | |||
for i := 0; i < len(user.Factors); i++ { |
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.
Thanks for the contribution! There's a user.HasMFAEnabled()
function I believe. Can consider using that . Otherwise no objections to this change - I think there might be some internal configuration we use to track claim additions, we will need to update that before merging this.
@tomekit For now I think it's best not to extend the default JWT. We've been talking internally about a different direction for this but have not fully decided yet. Basically have a In the mean time, it might be more useful to add this as an example in the Custom Access Token docs. |
Actually if you'd like to update your PR to include |
aal2
only if 2FA is enabled on user's account
Hi Supabase team,
This is to satisfy setup in which
supabase/auth
genereated JWT can be passed to external API which validates JWT validity on its own. With this change the external API can determine whether to enforceaal2
level or not, based onhas_factor
boolean which determines if user has at least one verified factor.Commit description:
Please let me know if you would be happy to merge that into your codebase.