Skip to content

Commit

Permalink
Merge pull request #4 from kazeburo/validate-signed-method
Browse files Browse the repository at this point in the history
validate signed method
  • Loading branch information
kazeburo committed Apr 22, 2019
2 parents 1665950 + d643afb commit 7ffd4ff
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 7ffd4ff

Please sign in to comment.