Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Put scope validation where claims are known
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Jun 10, 2024
1 parent c2a2ab1 commit 875ce72
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func decodeAuthToken(authHeader string) (jwt.MapClaims, error) {
return nil, err
}

tokenScope := fmt.Sprint(claims["scope"])
if tokenScope != ExpectedScope {
return nil, fmt.Errorf("invalid scope")
}

// Check if the token is valid and return the claims.
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
// Validate scope
tokenScope := fmt.Sprint(claims["scope"])
if tokenScope != ExpectedScope {
return nil, fmt.Errorf("invalid scope")
}
return claims, nil
} else {
return nil, fmt.Errorf("invalid token")
Expand Down

0 comments on commit 875ce72

Please sign in to comment.