Example #1
0
        private void DetachAuthenticationhandler(AuthenticationHandler handler)
        {
            var auth = handler.HttpContext.Features.Get <IHttpAuthenticationFeature>();

            if (auth != null)
            {
                auth.Handler = handler.PriorHandler;
            }
        }
Example #2
0
        private void AttachAuthenticationHandler(AuthenticationHandler handler)
        {
            var auth = handler.HttpContext.Features.Get <IHttpAuthenticationFeature>();

            if (auth == null)
            {
                auth = new HttpAuthenticationFeature();
                handler.HttpContext.Features.Set(auth);
            }
            handler.PriorHandler = auth.Handler;
            auth.Handler         = handler;
        }
        public async Task Invoke(HttpContext httpContext)
        {
            UpdateScheme(httpContext);

            UpdateRemoteIp(httpContext);

            var winPrincipal = UpdateUser(httpContext);

            var handler = new AuthenticationHandler(httpContext, _options, winPrincipal);
            AttachAuthenticationHandler(handler);

            try
            {
                await _next(httpContext);
            }
            finally
            {
                DetachAuthenticationhandler(handler);
            }
        }
Example #4
0
        public async Task Invoke(HttpContext httpContext)
        {
            UpdateScheme(httpContext);

            UpdateRemoteIp(httpContext);

            var winPrincipal = UpdateUser(httpContext);

            var handler = new AuthenticationHandler(httpContext, _options, winPrincipal);

            AttachAuthenticationHandler(handler);

            try
            {
                await _next(httpContext);
            }
            finally
            {
                DetachAuthenticationhandler(handler);
            }
        }
 private void DetachAuthenticationhandler(AuthenticationHandler handler)
 {
     var auth = handler.HttpContext.Features.Get<IHttpAuthenticationFeature>();
     if (auth != null)
     {
         auth.Handler = handler.PriorHandler;
     }
 }
 private void AttachAuthenticationHandler(AuthenticationHandler handler)
 {
     var auth = handler.HttpContext.Features.Get<IHttpAuthenticationFeature>();
     if (auth == null)
     {
         auth = new HttpAuthenticationFeature();
         handler.HttpContext.Features.Set(auth);
     }
     handler.PriorHandler = auth.Handler;
     auth.Handler = handler;
 }