You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may or may not be an issue depending on how you view it.
If you take this approach:
// Sample of a JSON access token (you got it through previous steps)consttokenObject={'access_token': '<access-token>','refresh_token': '<refresh-token>','expires_in': '7200'};// Create the access token wrapperlettoken=oauth2.accessToken.create(tokenObject);// Check if the token is expired. If expired it is refreshed.if(token.expired()){token.refresh().then((result)=>{token=result;});}
Then there is an inherent race condition when checking the expiration time against the time the token actually expires:
Server creates access token with expiration time (for example 7200 seconds from time t0)
Response is received and processed by the client after time t_l1
Client checks if token is expired (not expired according to the client) and issues its next API request.
Server receives and checks access token expiration after time t_l2, sees that token has expired.
There is a window of time where the latency of t_l1 + t_l2 (plus a ton of other small contributors to latency) could cause the client to use the access token, but for the server to reject it due to expiration.
One approach to fixing this would be to add a buffer; however, I can definitely see this being an issue for the consumer of the simple-oauth2 library to solve. Thoughts @jonathansamines ?
The text was updated successfully, but these errors were encountered:
sudowork
added a commit
to sudowork/simple-oauth2
that referenced
this issue
May 10, 2017
When checking if an access token has expired, there is a common race
condition where using a near-expiring token may actually be expired by
the time the API server checks it. This is due to things like round-trip
latency, clock skew, processing time, etc.
One solution is to allow clients to configure a buffer so that a token
will be reported as "expired" before it actually is. This allows some
leeway to account for various latencies.
Fixeslelylan#131
This may or may not be an issue depending on how you view it.
If you take this approach:
Then there is an inherent race condition when checking the expiration time against the time the token actually expires:
t0
)t_l1
t_l2
, sees that token has expired.There is a window of time where the latency of
t_l1
+t_l2
(plus a ton of other small contributors to latency) could cause the client to use the access token, but for the server to reject it due to expiration.One approach to fixing this would be to add a buffer; however, I can definitely see this being an issue for the consumer of the
simple-oauth2
library to solve. Thoughts @jonathansamines ?The text was updated successfully, but these errors were encountered: