Ejemplo n.º 1
0
 public async Task AuthenticateAsync(AuthenticateContext context)
 {
     if (PriorHandler != null)
     {
         await PriorHandler.AuthenticateAsync(context);
         if (_transform != null && context?.Principal != null)
         {
             var transformationContext = new ClaimsTransformationContext(_httpContext)
             {
                 Principal = context.Principal
             };
             context.Authenticated(
                 await _transform.TransformAsync(transformationContext),
                 context.Properties,
                 context.Description);
         }
     }
 }
 public async Task Invoke(HttpContext context)
 {
     var handler = new ClaimsTransformationHandler(Options.Transformer, context);
     handler.RegisterAuthenticationHandler(context.GetAuthentication());
     try
     {
         if (Options.Transformer != null)
         {
             var transformationContext = new ClaimsTransformationContext(context)
             {
                 Principal = context.User
             };
             context.User = await Options.Transformer.TransformAsync(transformationContext);
         }
         await _next(context);
     }
     finally
     {
         handler.UnregisterAuthenticationHandler(context.GetAuthentication());
     }
 }
Ejemplo n.º 3
0
 public virtual Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext context)
 {
     return OnTransform?.Invoke(context) ?? Task.FromResult(context.Principal);
 }