Пример #1
0
        public static void DetachAuthenticationHandler(this HttpContext context, IForwardingAuthenticationHandler handler)
        {
            var auth = context.Features.Get <IHttpAuthenticationFeature>();

            if (auth != null)
            {
                auth.Handler = handler.PriorHandler;
            }
        }
Пример #2
0
        public static void AttachAuthenticationHandler(this HttpContext context, IForwardingAuthenticationHandler handler, ClaimsPrincipal user = null)
        {
            var auth = context.Features.Get <IHttpAuthenticationFeature>();

            if (auth == null)
            {
                auth = new HttpAuthenticationFeature();
                context.Features.Set(auth);
            }

            auth.User    = user;
            context.User = user;

            handler.PriorHandler = auth.Handler;
            auth.Handler         = handler;
        }