Skip to content

Commit

Permalink
validate signed method
Browse files Browse the repository at this point in the history
  • Loading branch information
kazeburo committed Apr 22, 2019
1 parent 1665950 commit d643afb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions publickey/publickey.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ func (pk Publickey) Verify(t string) (bool, error) {
}
t = strings.TrimPrefix(t, "Bearer ")
claims := &jwt.StandardClaims{}
token, err := jwt.ParseWithClaims(t, claims, func(token *jwt.Token) (interface{}, error) {
jwp := &jwt.Parser{
ValidMethods: []string{"RS256", "RS384", "RS512"},
SkipClaimsValidation: false,
}
_, err := jwp.ParseWithClaims(t, claims, func(token *jwt.Token) (interface{}, error) {
return pk.verifyKey, nil
})

if err != nil {
return false, fmt.Errorf("Token is invalid: %v", err)
}
if !token.Valid {
return false, fmt.Errorf("Token is invalid")
}
if claims.Valid() != nil {
return false, fmt.Errorf("Invalid claims: %v", claims.Valid())
}

return true, nil
}

0 comments on commit d643afb

Please sign in to comment.