diff --git a/modules/openiddict/app/OpenIddict.Demo.Client.Console/Program.cs b/modules/openiddict/app/OpenIddict.Demo.Client.Console/Program.cs index 501cf0b543..2e55cc24b1 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Client.Console/Program.cs +++ b/modules/openiddict/app/OpenIddict.Demo.Client.Console/Program.cs @@ -134,7 +134,7 @@ tokenResponse = await client.RequestClientCredentialsTokenAsync(new ClientCreden ClientId = clientId, ClientSecret = clientSecret, - Scope = "AbpAPI profile roles email phone offline_access", + Scope = "AbpAPI offline_access", }); if (tokenResponse.IsError) diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.ClientCredentials.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.ClientCredentials.cs index 09f685ac83..f3cdd54485 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.ClientCredentials.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.ClientCredentials.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Collections.Immutable; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -47,27 +45,8 @@ public partial class TokenController principal.SetScopes(request.GetScopes()); principal.SetResources(await GetResourcesAsync(request.GetScopes())); - foreach (var claim in principal.Claims) - { - claim.SetDestinations(GetDestinations(claim)); - } + await OpenIddictClaimsPrincipalManager.HandleAsync(request, principal); return SignIn(principal, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); } - - - protected virtual IEnumerable GetDestinations(Claim claim) - { - // Note: by default, claims are NOT automatically included in the access and identity tokens. - // To allow OpenIddict to serialize them, you must attach them a destination, that specifies - // whether they should be included in access tokens, in identity tokens or in both. - - return claim.Type switch { - OpenIddictConstants.Claims.PreferredUsername or OpenIddictConstants.Claims.Subject - => ImmutableArray.Create(OpenIddictConstants.Destinations.AccessToken, - OpenIddictConstants.Destinations.IdentityToken), - - _ => ImmutableArray.Create(OpenIddictConstants.Destinations.AccessToken) - }; - } }