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
{{ message }}
Repository navigation
Commit 25afe85
Browse filesBrowse the repository at this point in the historyBrowse files
feat(oauth2): add jitter to access token lifetime on refresh_token grant (#172)
* feat(oauth2): add jitter to access token lifetime on refresh_token grant
Tokens issued by the refresh_token grant now get
lifetime - random_int(0, OAuth2.AccessToken.RefreshJitter), so clients that
refresh in the same minute spread out instead of hitting /oauth2/token in
synchronized bursts. The jittered value feeds expires_in, the access token DB
row and the Redis TTL. Other grants are unchanged.
The jitter defaults to 720s (server.OAuth2_AccessToken_RefreshJitter), is
clamped so the issued lifetime stays >= 60s and <= the configured lifetime,
and is editable from the admin server-config screen (0 disables).
* test(oauth2): assert refreshed token ttl right after each refresh
The redis ttl starts counting down as soon as the access token is stored, so
reading it only after all five refreshes made the 5s lower bound depend on
how long the remaining refreshes took. Run the DB lifetime and ttl checks in a
per-refresh callback instead.
* fix(oauth2): load access tokens with their stored lifetime
TokenService::getAccessToken rebuilt the token with the configured
OAuth2.AccessToken.Lifetime instead of the lifetime it was issued with, which
is already present on the redis hash and on DB. Access tokens issued by the
refresh_token grant now carry a jittered lifetime, so introspection reported a
remaining lifetime up to the jitter longer than the real one and resource
servers that cache the introspection result (summit-api) kept accepting the
token after the IDP had expired it.
Use the stored lifetime when reloading the token and assert on the test that
introspection expires_in matches the refresh response.
* test(oauth2): cover the refresh jitter clamp at the 60s floor
With a configured lifetime 40s above MinRefreshedAccessTokenLifetime and a
720s jitter the issued lifetime stays within [60, lifetime]; with the lifetime
at the floor the jitter is disabled and the lifetime is issued unchanged.
* fix(oauth2): raise the refreshed access token lifetime floor to 300s
openstack-uicore-foundation subtracts a 60s skew from expires_in before
deciding to refresh, so a jittered lifetime at the previous 60s floor would
have made summit-admin and event-site refresh on every API call. Keep the
floor well above that skew; the clamp test follows the constant.
<labelfor="oauth2-access-token-refresh-jitter">Access Token Refresh Jitter <spanclass="glyphicon glyphicon-info-sign accordion-toggle"aria-hidden="true"title="in seconds - max random reduction applied to the lifetime of access tokens issued on refresh - zero value disables"></span></label>
0 commit comments