Skip to content

Instantly share code, notes, and snippets.

@mogeta

mogeta/JWK.go

Created Mar 20, 2021
Embed
What would you like to do?
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