-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Gathering opinions on how long our new OAuth tokens should be valid for. The new system has two relevant types of tokens:
- access tokens: used for gaining access to a service, typically short-lived, analogous to our DataONE JWT token
- refresh tokens: used for getting a new access token without logging in again, typically much longer lasting, can be set to be revoked after a certain number of uses
On the keycloak side, login establishes a "Session" which has a limited duration, and an idle policy. These cumulatively define how long a refresh token is good for and are defined as:
- SSO Session Idle: maximum time a session can remain inactive. Activity is determined by the user contacting the keycloak server (for example, asking for a new access token using their refresh token)
- SSO Session Max: Max time before a session is expired. All tokens expire at this time, and the user must log back in.
Currently, our DataONE JWT tokens typically expire after 18 hours, or when the SSL signing key changes, whichever happens first. We also issue long-lived tokens which expire months later, or when the signing key changes. Both of these are dangerous because we can't easily revoke them.
For OIDC, the recommended pattern is to use short access tokens (e.g., 5 minutes) and longer sessions (e.g., 30 minutes). A client then needs to carefully monitor the expiration times. If an access token expires, they can request new tokens (both access and refresh) from the keycloak server as long as they have a refresh token and the session hasn't gone idle or hit its max. So, basically, once every 5 minutes to 30 minutes (depending on user activity) the client would have to request new tokens. They get both an access token and a refresh token back, so the countdown time starts again each time, and sessions can stay open as long as they are actively refreshed up to the SSO Session Max limit. After that, they have to log in again.
Asking for new tokens every 5 minutes can be painful, especially if some operations can take more than 5 minutes to complete. So, some groups set longer expiration windows. For example, having access tokens last an hour and sessions last a week is not uncommon. The longer the window, the bigger the risk that someone might be able to exploit a hijacked token. Having a long session max doesn't necessarily help if you have a shorter session idle, because a user that goes away for a few hours is likely to idle out even if they are nowhere near their session max time.
Proposed configuration
- Access token: Expires in 1 hour
- Refresh token:
- Revoked after use, so can only be used once, and the client needs to save the new refresh token
- SSO Session Idle: 18 hours
- SSO Session Max: 7 days
This means, 1) clients will have to regularly refresh access tokens but have a good window to work in. 2) if clients go inactive (e.g., overnight), they still have 18 hours to refresh -- so a user that puts down work at 6pm in MetacatUI can pick up again without logging in again until noon the next day, so long as the client asks for a new access token in that window. All clients have to re-login once every 7 days.
Feedback appreciated @regetz @rushirajnenuji @taojing2002 @robyngit @artntek ...
Metadata
Metadata
Assignees
Labels
Type
Projects
Status