@@ -95,7 +95,7 @@ def create_authorization_code(self, authorization_request, subject_identifier, s
9595 authorization_code = rand_str ()
9696 authz_info = {
9797 'used' : False ,
98- 'exp' : time .time () + self .authorization_code_lifetime ,
98+ 'exp' : int ( time .time () ) + self .authorization_code_lifetime ,
9999 'sub' : subject_identifier ,
100100 'granted_scope' : scope ,
101101 self .KEY_AUTHORIZATION_REQUEST : authorization_request .to_dict ()
@@ -129,8 +129,8 @@ def _create_access_token(self, subject_identifier, auth_req, granted_scope, curr
129129 logger .debug ('creating access token for scope=%s' , scope )
130130
131131 authz_info = {
132- 'iat' : time .time (),
133- 'exp' : time .time () + self .access_token_lifetime ,
132+ 'iat' : int ( time .time () ),
133+ 'exp' : int ( time .time () ) + self .access_token_lifetime ,
134134 'sub' : subject_identifier ,
135135 'client_id' : auth_req ['client_id' ],
136136 'aud' : [auth_req ['client_id' ]],
@@ -157,9 +157,9 @@ def exchange_code_for_token(self, authorization_code):
157157 if authz_info ['used' ]:
158158 logger .debug ('detected already used authz_code=%s' , authorization_code )
159159 raise InvalidAuthorizationCode ('{} has already been used' .format (authorization_code ))
160- elif authz_info ['exp' ] < time .time ():
160+ elif authz_info ['exp' ] < int ( time .time () ):
161161 logger .debug ('detected expired authz_code=%s, now=%s > exp=%s ' ,
162- authorization_code , time .time (), authz_info ['exp' ])
162+ authorization_code , int ( time .time () ), authz_info ['exp' ])
163163 raise InvalidAuthorizationCode ('{} has expired' .format (authorization_code ))
164164
165165 authz_info ['used' ] = True
@@ -181,7 +181,7 @@ def introspect_access_token(self, access_token_value):
181181
182182 authz_info = self .access_tokens [access_token_value ]
183183
184- introspection = {'active' : authz_info ['exp' ] >= time .time ()}
184+ introspection = {'active' : authz_info ['exp' ] >= int ( time .time () )}
185185
186186 introspection_params = {k : v for k , v in authz_info .items () if k in TokenIntrospectionResponse .c_param }
187187 introspection .update (introspection_params )
@@ -200,7 +200,7 @@ def create_refresh_token(self, access_token_value):
200200 return None
201201
202202 refresh_token = rand_str ()
203- authz_info = {'access_token' : access_token_value , 'exp' : time .time () + self .refresh_token_lifetime }
203+ authz_info = {'access_token' : access_token_value , 'exp' : int ( time .time () ) + self .refresh_token_lifetime }
204204 self .refresh_tokens [refresh_token ] = authz_info
205205
206206 logger .debug ('issued refresh_token=%s expiring=%d for access_token=%s' , refresh_token , authz_info ['exp' ],
@@ -218,7 +218,7 @@ def use_refresh_token(self, refresh_token, scope=None):
218218 raise InvalidRefreshToken ('{} unknown' .format (refresh_token ))
219219
220220 refresh_token_info = self .refresh_tokens [refresh_token ]
221- if 'exp' in refresh_token_info and refresh_token_info ['exp' ] < time .time ():
221+ if 'exp' in refresh_token_info and refresh_token_info ['exp' ] < int ( time .time () ):
222222 raise InvalidRefreshToken ('{} has expired' .format (refresh_token ))
223223
224224 authz_info = self .access_tokens [refresh_token_info ['access_token' ]]
@@ -240,7 +240,7 @@ def use_refresh_token(self, refresh_token, scope=None):
240240 new_refresh_token = None
241241 if self .refresh_token_threshold \
242242 and 'exp' in refresh_token_info \
243- and refresh_token_info ['exp' ] - time .time () < self .refresh_token_threshold :
243+ and refresh_token_info ['exp' ] - int ( time .time () ) < self .refresh_token_threshold :
244244 # refresh token is close to expiry, issue a new one
245245 new_refresh_token = self .create_refresh_token (new_access_token .value )
246246 else :
0 commit comments