Skip to content

Instantly share code, notes, and snippets.

@programatt
Last active March 29, 2017 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programatt/562fecc52318cf7143e118174d36e4b1 to your computer and use it in GitHub Desktop.
Save programatt/562fecc52318cf7143e118174d36e4b1 to your computer and use it in GitHub Desktop.
// 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