-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
OAuth: Introduce user_refresh_token setting and make it default for the selected providers #71533
Conversation
To enable a refresh token for AzureAD, extend the `scopes` in `[auth.azuread]` with `offline_access`. | ||
Refresh token fetching and access token expiration check is enabled by default for the AzureAD provider since Grafana v10.1.0 if the `accessTokenExpirationCheck` feature toggle is enabled. If you would like to disable access token expiration check then set the `use_refresh_token` configuration value to `false`. | ||
|
||
> **Note:** The `accessTokenExpirationCheck` feature toggle will be removed in Grafana v10.2.0 and the `use_refresh_token` configuration value will be used instead for configuring refresh token fetching and access token expiration check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: review deployment plan
docs/sources/setup-grafana/configure-security/configure-authentication/generic-oauth/index.md
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, have not reviewed any of the doc updates
@@ -114,7 +114,7 @@ func (s *SocialGoogle) extractFromAPI(ctx context.Context, client *http.Client) | |||
} | |||
|
|||
func (s *SocialGoogle) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string { | |||
if s.features.IsEnabled(featuremgmt.FlagAccessTokenExpirationCheck) { | |||
if s.features.IsEnabled(featuremgmt.FlagAccessTokenExpirationCheck) && s.useRefreshToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any plans on removing the feature toggle and only check useRefreshToken
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, that's the plan! (having a setting by auth provider, instead of having a global setting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @mgyongyosi!!
What is this feature?
This PR introduces the
use_refresh_token
configuration parameter to each of the OAuth providers and extend the defaults.ini file with the default value for each provider.It would be enabled by default for the following providers (check the documentation in case you would like to enable it for other providers):
Currently this functionality is behind a feature toggle called
accessTokenExpirationCheck
which means that the feature toggle must be enabled to use refresh tokens.accessTokenExpirationCheck
feature toggle will be removed in Grafana v10.2 and only theuse_refresh_token
setting of the providers will be used to specify whether an OAuth provider should use refresh tokens and check the access token expiration.Why do we need this feature?
We need this to improve the security of Grafana, because currently the OAuth providers are used only for logging users in. With Grafana v9.3 we introduced a feature toggle
accessTokenExpirationCheck
that enables the access token expiration check and refreshes the access token using the refresh token. However, we decided that it would be more convenient to set the expiration check and refresh token fetching by OAuth providers and to enable it by default for the providers that either provides a refresh token by default or getting the refresh token is controlled by the client.Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
Please check that: