From bfc2380320da935fe5c4a5df05c1bd6b7d03b0bb Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 17 Jul 2021 09:00:42 +0100 Subject: [PATCH] Enable custom JWT token audiences (#649) --- fastapi_users/authentication/jwt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fastapi_users/authentication/jwt.py b/fastapi_users/authentication/jwt.py index 006bc773..9aa94f64 100644 --- a/fastapi_users/authentication/jwt.py +++ b/fastapi_users/authentication/jwt.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, Optional, List import jwt from fastapi import Response @@ -22,7 +22,7 @@ class JWTAuthentication(BaseAuthentication[str]): """ scheme: OAuth2PasswordBearer - token_audience: str = "fastapi-users:auth" + token_audience: List[str] = ["fastapi-users:auth"] secret: str lifetime_seconds: int @@ -32,10 +32,12 @@ class JWTAuthentication(BaseAuthentication[str]): lifetime_seconds: int, tokenUrl: str = "auth/jwt/login", name: str = "jwt", + token_audience: List[str] = ["fastapi-users:auth"] ): super().__init__(name, logout=False) self.scheme = OAuth2PasswordBearer(tokenUrl, auto_error=False) self.secret = secret + self.token_audience = token_audience self.lifetime_seconds = lifetime_seconds async def __call__(