Separate two cases for validation of aud
claim.
This commit is contained in:
parent
4e0d06bb67
commit
546d1a9cbe
@ -136,10 +136,13 @@ proc validateJWT*(ctx: ApiAuthContext, jwt: JWT) =
|
|||||||
|
|
||||||
if jwt.header.alg.isNone: failAuth "Missing 'alg' header property."
|
if jwt.header.alg.isNone: failAuth "Missing 'alg' header property."
|
||||||
|
|
||||||
if jwt.claims.aud.isNone or
|
if jwt.claims.aud.isNone: failAuth "Missing 'aud' claim."
|
||||||
not ctx.validAudiences.contains(jwt.claims.aud.get):
|
|
||||||
|
if not ctx.validAudiences.contains(jwt.claims.aud.get):
|
||||||
|
log.debug(
|
||||||
|
"Valid audiences: $#\ttoken audience: $#" %
|
||||||
|
[$ctx.validAudiences, jwt.claims.aud.get])
|
||||||
failAuth "JWT is not for us (invalid audience)."
|
failAuth "JWT is not for us (invalid audience)."
|
||||||
failAuth "Issuer is trusted, but the token is not for the expected audience."
|
|
||||||
|
|
||||||
let signingAlgorithm = jwt.header.alg.get
|
let signingAlgorithm = jwt.header.alg.get
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user