React to Authentication changes.
This commit is contained in:
parent
2fe2e0d841
commit
c93e4f09f2
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
|
using Microsoft.AspNet.Http.Authentication;
|
||||||
using Microsoft.AspNet.Http.Features.Authentication;
|
using Microsoft.AspNet.Http.Features.Authentication;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.IISPlatformHandler
|
namespace Microsoft.AspNet.IISPlatformHandler
|
||||||
|
|
@ -121,7 +122,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
|
||||||
|
|
||||||
private bool ShouldHandleScheme(string authenticationScheme)
|
private bool ShouldHandleScheme(string authenticationScheme)
|
||||||
{
|
{
|
||||||
if (Options.AutomaticAuthentication && string.IsNullOrEmpty(authenticationScheme))
|
if (Options.AutomaticAuthentication && string.Equals(AuthenticationManager.AutomaticScheme, authenticationScheme, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
|
using Microsoft.AspNet.Http.Authentication;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace TestSites
|
namespace TestSites
|
||||||
|
|
@ -12,6 +14,26 @@ namespace TestSites
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
loggerFactory.AddConsole();
|
loggerFactory.AddConsole();
|
||||||
|
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await next();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (context.Response.HasStarted)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Response.Clear();
|
||||||
|
context.Response.StatusCode = 500;
|
||||||
|
await context.Response.WriteAsync(ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.UseIISPlatformHandler();
|
app.UseIISPlatformHandler();
|
||||||
app.Use((context, next) =>
|
app.Use((context, next) =>
|
||||||
{
|
{
|
||||||
|
|
@ -34,7 +56,7 @@ namespace TestSites
|
||||||
|
|
||||||
if (context.Request.Path.Equals("/Forbidden"))
|
if (context.Request.Path.Equals("/Forbidden"))
|
||||||
{
|
{
|
||||||
return context.Authentication.ForbidAsync(string.Empty);
|
return context.Authentication.ForbidAsync(AuthenticationManager.AutomaticScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.Request.Path.Equals("/AutoForbid"))
|
if (context.Request.Path.Equals("/AutoForbid"))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue