This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 994
Support array in "aud" claim #445
Comments
Hey, we have the same issue when going from v3 to v4. Best, |
Scrap that, I just realised that the v4 branch has this sorted here. |
we just removed the validation as workaround btw |
That's just wrong. |
For those that are stuck in version 3.x for the time being, this work around does the trick: func verifyAudience(claims jwt.MapClaims, audience string) bool {
original := claims["aud"]
switch aud := claims["aud"].(type) {
case string:
return claims.VerifyAudience(audience, true)
case []interface{}:
for _, val := range aud {
if s, ok := val.(string); ok {
claims["aud"] = s
if claims.VerifyAudience(audience, true) {
claims["aud"] = original
return true
}
}
}
}
claims["aud"] = original
return false
} So instead of calling the valid := claims.VerifyAudience("some.audience", true); it would instead be: valid := verifyAudience(claims, "some.audience"); |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
According to the spec, "In the general case, the "aud" value is an array of case-sensitive strings, each containing a StringOrURI value." Can you update this library to support an array in the "aud" value?
Thanks,
Mike
The text was updated successfully, but these errors were encountered: