@@ -28,6 +28,7 @@ class SessionModule(Protocol):
2828 cookie_password : str
2929 jwks : PyJWKClient
3030 jwk_algorithms : List [str ]
31+ jwt_leeway : float
3132
3233 def __init__ (
3334 self ,
@@ -36,6 +37,7 @@ def __init__(
3637 client_id : str ,
3738 session_data : str ,
3839 cookie_password : str ,
40+ jwt_leeway : float = 0 ,
3941 ) -> None :
4042 # If the cookie password is not provided, throw an error
4143 if cookie_password is None or cookie_password == "" :
@@ -45,6 +47,7 @@ def __init__(
4547 self .client_id = client_id
4648 self .session_data = session_data
4749 self .cookie_password = cookie_password
50+ self .jwt_leeway = jwt_leeway
4851
4952 self .jwks = PyJWKClient (self .user_management .get_jwks_url ())
5053
@@ -89,6 +92,7 @@ def authenticate(
8992 signing_key .key ,
9093 algorithms = self .jwk_algorithms ,
9194 options = {"verify_aud" : False },
95+ leeway = self .jwt_leeway ,
9296 )
9397
9498 return AuthenticateWithSessionCookieSuccessResponse (
@@ -136,6 +140,7 @@ def _is_valid_jwt(self, token: str) -> bool:
136140 signing_key .key ,
137141 algorithms = self .jwk_algorithms ,
138142 options = {"verify_aud" : False },
143+ leeway = self .jwt_leeway ,
139144 )
140145 return True
141146 except jwt .exceptions .InvalidTokenError :
@@ -167,6 +172,7 @@ def __init__(
167172 client_id : str ,
168173 session_data : str ,
169174 cookie_password : str ,
175+ jwt_leeway : float = 0 ,
170176 ) -> None :
171177 # If the cookie password is not provided, throw an error
172178 if cookie_password is None or cookie_password == "" :
@@ -176,6 +182,7 @@ def __init__(
176182 self .client_id = client_id
177183 self .session_data = session_data
178184 self .cookie_password = cookie_password
185+ self .jwt_leeway = jwt_leeway
179186
180187 self .jwks = PyJWKClient (self .user_management .get_jwks_url ())
181188
@@ -228,6 +235,7 @@ def refresh(
228235 signing_key .key ,
229236 algorithms = self .jwk_algorithms ,
230237 options = {"verify_aud" : False },
238+ leeway = self .jwt_leeway ,
231239 )
232240
233241 return RefreshWithSessionCookieSuccessResponse (
@@ -257,6 +265,7 @@ def __init__(
257265 client_id : str ,
258266 session_data : str ,
259267 cookie_password : str ,
268+ jwt_leeway : float = 0 ,
260269 ) -> None :
261270 # If the cookie password is not provided, throw an error
262271 if cookie_password is None or cookie_password == "" :
@@ -266,6 +275,7 @@ def __init__(
266275 self .client_id = client_id
267276 self .session_data = session_data
268277 self .cookie_password = cookie_password
278+ self .jwt_leeway = jwt_leeway
269279
270280 self .jwks = PyJWKClient (self .user_management .get_jwks_url ())
271281
@@ -318,6 +328,7 @@ async def refresh(
318328 signing_key .key ,
319329 algorithms = self .jwk_algorithms ,
320330 options = {"verify_aud" : False },
331+ leeway = self .jwt_leeway ,
321332 )
322333
323334 return RefreshWithSessionCookieSuccessResponse (
0 commit comments