React to Authentication changes.

This commit is contained in:
Chris R 2015-10-15 10:09:33 -07:00
parent 2fe2e0d841
commit c93e4f09f2
2 changed files with 25 additions and 2 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Http.Features.Authentication;
namespace Microsoft.AspNet.IISPlatformHandler
@ -121,7 +122,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
private bool ShouldHandleScheme(string authenticationScheme)
{
if (Options.AutomaticAuthentication && string.IsNullOrEmpty(authenticationScheme))
if (Options.AutomaticAuthentication && string.Equals(AuthenticationManager.AutomaticScheme, authenticationScheme, StringComparison.Ordinal))
{
return true;
}

View File

@ -1,8 +1,10 @@
// 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 Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Authentication;
using Microsoft.Extensions.Logging;
namespace TestSites
@ -12,6 +14,26 @@ namespace TestSites
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
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.Use((context, next) =>
{
@ -34,7 +56,7 @@ namespace TestSites
if (context.Request.Path.Equals("/Forbidden"))
{
return context.Authentication.ForbidAsync(string.Empty);
return context.Authentication.ForbidAsync(AuthenticationManager.AutomaticScheme);
}
if (context.Request.Path.Equals("/AutoForbid"))