Skip to content

Commit

Permalink
Fix saving granted resource scopes in AuthorizationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-abblix committed Jul 5, 2024
1 parent e06354e commit 38016c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ public async Task<AuthorizationResponse> ProcessAsync(ValidAuthorizationRequest

var clientId = request.ClientInfo.ClientId;
var grantedConsents = userConsents.Granted;
var scopes = Array.ConvertAll(grantedConsents.Scopes, scope => scope.Scope);
var scopes = grantedConsents.Scopes
.Concat(grantedConsents.Resources.SelectMany(rd => rd.Scopes))
.Select(sd => sd.Scope)
.Distinct()
.ToArray();
var resources = Array.ConvertAll(grantedConsents.Resources, resource => resource.Resource);
var authContext = new AuthorizationContext(clientId, scopes, model.Claims)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public AuthorizationContext EvaluateAuthorizationContext(ValidTokenRequest reque
var resources = authContext.Resources;
if (resources is { Length: > 0 } && request.Resources is { Length: > 0 })
{
resources = resources.Intersect(from rd in request.Resources select rd.Resource).ToArray();
resources = resources
.Intersect(from rd in request.Resources select rd.Resource)
.ToArray();
}

// Return a new authorization context updated with the determined scopes and resources.
Expand Down

0 comments on commit 38016c2

Please sign in to comment.