Last active
March 29, 2017 13:18
-
-
Save programatt/562fecc52318cf7143e118174d36e4b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.Text.Encodings.Web; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Options; | |
namespace Microsoft.AspNetCore.Authentication | |
{ | |
public abstract class AuthenticationMiddleware<TOptions> where TOptions : AuthenticationOptions, new() | |
{ | |
... | |
//snipped for clarity | |
public async Task Invoke(HttpContext context) | |
{ | |
var handler = CreateHandler(); | |
await handler.InitializeAsync(Options, context, Logger, UrlEncoder); | |
try | |
{ | |
if (!await handler.HandleRequestAsync()) | |
{ | |
await _next(context); | |
} | |
} | |
finally | |
{ | |
try | |
{ | |
await handler.TeardownAsync(); | |
} | |
catch (Exception) | |
{ | |
// Don't mask the original exception, if any | |
} | |
} | |
} | |
... | |
//snipped for clarity | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment