public async Task Invoke(HttpContext context) { using (RequestServicesContainer.EnsureRequestServices(context, _services)) { AuthenticationHandler <TOptions> handler = CreateHandler(); await handler.Initialize(Options, context); try { if (!await handler.InvokeAsync()) { await _next(context); } } catch (Exception) { try { handler.Faulted = true; await handler.TeardownAsync(); } catch (Exception) { // Don't mask the original exception } throw; } await handler.TeardownAsync(); } }
public static object RegisterAuthenticationHandler(this HttpRequest request, AuthenticationHandler handler) { var chained = request.Get<AuthenticateDelegate>(Constants.SecurityAuthenticate); var hook = new Hook(handler, chained); request.Set<AuthenticateDelegate>(Constants.SecurityAuthenticate, hook.AuthenticateAsync); return hook; }
public async Task Invoke(HttpContext context) { using (RequestServicesContainer.EnsureRequestServices(context, _services)) { AuthenticationHandler <TOptions> handler = CreateHandler(); await handler.Initialize(Options, context); if (!await handler.InvokeAsync()) { await _next(context); } await handler.TeardownAsync(); } }
private static void OnSendingHeaderCallback(object state) { AuthenticationHandler handler = (AuthenticationHandler)state; handler.ApplyResponse(); }
public Hook(AuthenticationHandler handler, AuthenticateDelegate chained) { _handler = handler; Chained = chained; }