Skip to content

Commit

Permalink
Use email from JWT for user id (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
irees authored Oct 6, 2023
1 parent c294d7e commit 92330a1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion auth/ancheck/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func JWTMiddleware(jwtAudience string, jwtIssuer string, pubKeyPath string) (fun
}

type CustomClaimsExample struct {
Email string
jwt.StandardClaims
}

Expand All @@ -63,6 +64,6 @@ func validateJwt(rsaPublicKey *rsa.PublicKey, jwtAudience string, jwtIssuer stri
if !claims.VerifyIssuer(jwtIssuer, true) {
return nil, errors.New("invalid issuer")
}
user := authn.NewCtxUser(claims.Subject, "", "")
user := authn.NewCtxUser(claims.Email, claims.Subject, claims.Email)
return user, nil
}

0 comments on commit 92330a1

Please sign in to comment.