feat(auth): Add "offline_access" scope for long-lived refresh tokens #1943
+15
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add the
offline_access
scope when requesting authentication and refresh tokens in the CLI. This ensures that the authentication provider issues long-lived refresh tokens, allowing the CLI to obtain new access tokens without requiring the user to log in frequently.This allows for having long-lived refresh tokens for the CLI, while still having the refresh tokens for the web application expire after a shorter period of time in case there is no user activity.
Such refresh token will no langer have a
exp
(expiration) claim. However, in authentication providers like Keycloak there are policies that enable to invalidate them nevertheless after a period of time of inactivity. This mechanism allows to have a regular automatic clean-up of long-lived CLI sessions, avoiding the number of long-lived sessions to grow in Keycloak without any bounds.While for web applications it is good practice to invalidate the refresh token after 15 - 30 minutes of inactivity, for CLIs it is common to have them last for several hours or even days.