mirror of https://github.com/abpframework/abp.git
4 changed files with 51 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||
using System.Threading.Tasks; |
|||
using OpenIddict.Abstractions; |
|||
using OpenIddict.Server; |
|||
|
|||
namespace Volo.Abp.OpenIddict; |
|||
|
|||
public class RemoveClaimsFromClientCredentialsGrantType : IOpenIddictServerHandler<OpenIddictServerEvents.ProcessSignInContext> |
|||
{ |
|||
public static OpenIddictServerHandlerDescriptor Descriptor { get; } |
|||
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ProcessSignInContext>() |
|||
.AddFilter<OpenIddictServerHandlerFilters.RequireAccessTokenGenerated>() |
|||
.UseSingletonHandler<RemoveClaimsFromClientCredentialsGrantType>() |
|||
.SetOrder(OpenIddictServerHandlers.PrepareAccessTokenPrincipal.Descriptor.Order - 1) |
|||
.SetType(OpenIddictServerHandlerType.Custom) |
|||
.Build(); |
|||
|
|||
public ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context) |
|||
{ |
|||
if (context.Request.IsClientCredentialsGrantType()) |
|||
{ |
|||
if (context.Principal != null) |
|||
{ |
|||
context.Principal.RemoveClaims(OpenIddictConstants.Claims.Subject); |
|||
context.Principal.RemoveClaims(OpenIddictConstants.Claims.PreferredUsername); |
|||
} |
|||
} |
|||
|
|||
return default; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue