1 Commits
0.4.9 ... 0.3.1

2 changed files with 10 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# Package # Package
version = "0.3.0" version = "0.3.1"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Jonathan's opinionated extensions and auth layer for Jester." description = "Jonathan's opinionated extensions and auth layer for Jester."
license = "MIT" license = "MIT"

View File

@@ -140,10 +140,14 @@ proc validateJWT*(ctx: ApiAuthContext, jwt: JWT) =
if jwt.claims.aud.isNone: failAuth "Missing 'aud' claim." if jwt.claims.aud.isNone: failAuth "Missing 'aud' claim."
if jwt.claims["aud"].get.kind == JString:
# If the token is for a single audience, check that it is for us.
if not ctx.validAudiences.contains(jwt.claims.aud.get): if not ctx.validAudiences.contains(jwt.claims.aud.get):
log.debug( failAuth "JWT is not for us (invalid audience)."
"Valid audiences: $#\ttoken audience: $#" % elif jwt.claims["aud"].get.kind == JArray:
[$ctx.validAudiences, jwt.claims.aud.get]) # If the token is for multiple audiences, check that at least one is for us.
let auds = jwt.claims["aud"].get.getElems
if not auds.anyIt(ctx.validAudiences.contains(it.getStr)):
failAuth "JWT is not for us (invalid audience)." failAuth "JWT is not for us (invalid audience)."
let signingAlgorithm = jwt.header.alg.get let signingAlgorithm = jwt.header.alg.get