aspnetcore/src/Microsoft.AspNetCore.Authen.../ClaimsTransformer.cs

20 lines
664 B
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Authentication
{
public class ClaimsTransformer : IClaimsTransformer
{
public Func<ClaimsTransformationContext, Task<ClaimsPrincipal>> OnTransform { get; set; }
public virtual Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext context)
{
return OnTransform?.Invoke(context) ?? Task.FromResult(context.Principal);
}
}
}