File tree Expand file tree Collapse file tree 3 files changed +22
-21
lines changed
supertokens_python/recipe/session/with_jwt Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## unreleased
9
9
10
- ## [ 0.12.10] - 2023-09-28
10
+ ## [ 0.12.10] - 2023-09-01
11
11
12
12
- Add logic to retry network calls if the core returns status 429
13
+ - Fixes session recipe with jwt where the lifetime of the jwt is set to 1 in case it is ` < 1 `
13
14
14
15
## [ 0.12.9] - 2023-04-28
15
16
Original file line number Diff line number Diff line change @@ -159,16 +159,16 @@ async def jwt_aware_update_access_token_payload(
159
159
if decoded_payload is None or decoded_payload .get ("exp" ) is None :
160
160
raise Exception ("Error reading JWT from session" )
161
161
162
- jwt_expiry = 1
163
- if "exp" in decoded_payload :
164
- exp = decoded_payload [ "exp" ]
165
- if exp > current_time_in_seconds :
166
- # it can come here if someone calls this function well after
167
- # the access token and the jwt payload have expired. In this case,
168
- # we still want the jwt payload to update, but the resulting JWT should
169
- # not be alive for too long (since it's expired already). So we set it to
170
- # 1 second lifetime.
171
- jwt_expiry = exp - current_time_in_seconds
162
+ jwt_expiry = decoded_payload . get ( "exp" , 0 ) - current_time_in_seconds
163
+ # pylint: disable=consider-using-max-builtin
164
+ if jwt_expiry < 1 :
165
+ # it can come here if someone calls this function well after
166
+ # the access token and the jwt payload have expired. In this case,
167
+ # we still want the jwt payload to update, but the resulting JWT should
168
+ # not be alive for too long (since it's expired already). So we set it to
169
+ # 1 second lifetime.
170
+ jwt_expiry = 1
171
+ # pylint: enable=consider-using-max-builtin
172
172
173
173
new_access_token_payload = await add_jwt_to_access_token_payload (
174
174
access_token_payload = new_access_token_payload ,
Original file line number Diff line number Diff line change @@ -70,16 +70,16 @@ async def update_access_token_payload(
70
70
if decoded_payload is None or decoded_payload .get ("exp" ) is None :
71
71
raise Exception ("Error reading JWT from session" )
72
72
73
- jwt_expiry = 1
74
- if "exp" in decoded_payload :
75
- exp = decoded_payload [ "exp" ]
76
- if exp > current_time_in_seconds :
77
- # it can come here if someone calls this function well after
78
- # the access token and the jwt payload have expired. In this case,
79
- # we still want the jwt payload to update, but the resulting JWT should
80
- # not be alive for too long (since it's expired already). So we set it to
81
- # 1 second lifetime.
82
- jwt_expiry = exp - current_time_in_seconds
73
+ jwt_expiry = decoded_payload . get ( "exp" , 0 ) - current_time_in_seconds
74
+ # pylint: disable=consider-using-max-builtin
75
+ if jwt_expiry < 1 :
76
+ # it can come here if someone calls this function well after
77
+ # the access token and the jwt payload have expired. In this case,
78
+ # we still want the jwt payload to update, but the resulting JWT should
79
+ # not be alive for too long (since it's expired already). So we set it to
80
+ # 1 second lifetime.
81
+ jwt_expiry = 1
82
+ # pylint: enable=consider-using-max-builtin
83
83
84
84
new_access_token_payload = await add_jwt_to_access_token_payload (
85
85
access_token_payload = new_access_token_payload ,
You can’t perform that action at this time.
0 commit comments