Created
March 20, 2021 02:45
-
-
Save mogeta/af24a38008a4ae1e9b49c9bf9391d43b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getJWKKey(token *jwt.Token) (interface{}, error) { | |
kid := fmt.Sprintf("%v", token.Header["kid"]) | |
set, err := jwk.FetchHTTP(jwkKeyURL) | |
if err != nil { | |
log.Printf("failed to parse JWK: %s", err) | |
return nil, err | |
} | |
keys := set.LookupKeyID(kid) | |
var publicKey interface{} | |
keys[0].Raw(&publicKey) | |
return publicKey, nil | |
} | |
func fetchClaim(token string) *EVEClaim { | |
claim := &EVEClaim{} | |
_, err := jwt.ParseWithClaims(token, claim, getJWKKey) | |
if err != nil { | |
log.Fatal(err) | |
} | |
return claim | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment