-
Notifications
You must be signed in to change notification settings - Fork 674
Append offline_access to authorization scope when AS advertises it (SEP-2207)
#1479
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -492,6 +492,7 @@ private Uri BuildAuthorizationUrl( | |||||
| } | ||||||
|
|
||||||
| var scope = GetScopeParameter(protectedResourceMetadata); | ||||||
| scope = AugmentScopeWithOfflineAccess(scope, authServerMetadata); | ||||||
| if (!string.IsNullOrEmpty(scope)) | ||||||
| { | ||||||
| queryParamsDictionary["scope"] = scope!; | ||||||
|
|
@@ -726,6 +727,37 @@ private async Task PerformDynamicClientRegistrationAsync( | |||||
| return _configuredScopes; | ||||||
| } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Augments the scope parameter with <c>offline_access</c> if the authorization server advertises it in | ||||||
| /// <c>scopes_supported</c> and it is not already present. This signals to OIDC-flavored authorization servers | ||||||
| /// that the client desires a refresh token, per SEP-2207. | ||||||
| /// </summary> | ||||||
| private static string? AugmentScopeWithOfflineAccess(string? scope, AuthorizationServerMetadata authServerMetadata) | ||||||
| { | ||||||
| const string offlineAccess = "offline_access"; | ||||||
|
|
||||||
| if (authServerMetadata.ScopesSupported is null || !authServerMetadata.ScopesSupported.Contains(offlineAccess)) | ||||||
|
||||||
| if (authServerMetadata.ScopesSupported is null || !authServerMetadata.ScopesSupported.Contains(offlineAccess)) | |
| if (authServerMetadata.ScopesSupported?.Contains(offlineAccess) is not true) |
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.
Applied in 6a23554.
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.
Is this correct if scope is null?
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.
Yes — when the AS doesn't advertise offline_access, we return the scope unchanged regardless of its value (including null). The caller already handles null scope by not adding the scope query parameter at all, which is the correct behavior.
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.
consts should be PascalCased
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.
Fixed in 6a23554 — renamed to
OfflineAccess.