Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): Add "offline_access" scope for long-lived refresh tokens #1943

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wkl3nk
Copy link
Contributor

@wkl3nk wkl3nk commented Feb 3, 2025

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.

@wkl3nk wkl3nk force-pushed the wkl3nk/add-offline-access-scope-to-cli branch from 43f88ff to 24231d2 Compare February 3, 2025 14:54
@wkl3nk wkl3nk force-pushed the wkl3nk/add-offline-access-scope-to-cli branch 2 times, most recently from cdf7f61 to 57f3d41 Compare February 3, 2025 16:15
@wkl3nk wkl3nk requested a review from MarcelBochtler February 3, 2025 16:19
@wkl3nk wkl3nk force-pushed the wkl3nk/add-offline-access-scope-to-cli branch from 57f3d41 to df81e58 Compare February 4, 2025 07:24
@wkl3nk wkl3nk force-pushed the wkl3nk/add-offline-access-scope-to-cli branch 2 times, most recently from fe649b1 to e7fe7ca Compare February 4, 2025 11:19
@wkl3nk wkl3nk requested a review from MarcelBochtler February 4, 2025 11:19
Add the "offline_access" scope when requesting authentication and
refresh tokens. 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.

Signed-off-by: Wolfgang Klenk <wolfgang.klenk2@bosch.com>
@wkl3nk wkl3nk force-pushed the wkl3nk/add-offline-access-scope-to-cli branch from e7fe7ca to d1922a0 Compare February 4, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants