fix: need to pass the claim by ref

This commit is contained in:
Derrick Hammer 2024-02-17 20:11:43 -05:00
parent fc1dd491d6
commit 7ec03524ed
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 4 additions and 4 deletions

View File

@ -11,10 +11,10 @@ import (
)
type JWTPurpose string
type VerifyTokenFunc func(claim jwt.RegisteredClaims) error
type VerifyTokenFunc func(claim *jwt.RegisteredClaims) error
var (
nopVerifyFunc VerifyTokenFunc = func(claim jwt.RegisteredClaims) error {
nopVerifyFunc VerifyTokenFunc = func(claim *jwt.RegisteredClaims) error {
return nil
}
@ -84,7 +84,7 @@ func JWTVerifyToken(token string, domain string, privateKey ed25519.PrivateKey,
return nil, fmt.Errorf("%w: %s", ErrJWTUnexpectedIssuer, claim.Issuer)
}
err = verifyFunc(validatedToken.Claims.(jwt.RegisteredClaims))
err = verifyFunc(claim)
return nil, err
}

View File

@ -125,7 +125,7 @@ func AuthMiddleware(options AuthMiddlewareOptions) func(http.Handler) http.Handl
return
}
claim, err := account.JWTVerifyToken(authToken, domain, options.Identity, func(claim jwt.RegisteredClaims) error {
claim, err := account.JWTVerifyToken(authToken, domain, options.Identity, func(claim *jwt.RegisteredClaims) error {
aud, _ := claim.GetAudience()
if slices.Contains[jwt.ClaimStrings, string](aud, string(options.Purpose)) == false {