From c93e4f09f2e5648c70bfa86748911f7ea0c18148 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 15 Oct 2015 10:09:33 -0700 Subject: [PATCH] React to Authentication changes. --- .../AuthenticationHandler.cs | 3 ++- test/TestSites/StartupNtlmAuthentication.cs | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.IISPlatformHandler/AuthenticationHandler.cs b/src/Microsoft.AspNet.IISPlatformHandler/AuthenticationHandler.cs index 118364cf70..ea0df4fcad 100644 --- a/src/Microsoft.AspNet.IISPlatformHandler/AuthenticationHandler.cs +++ b/src/Microsoft.AspNet.IISPlatformHandler/AuthenticationHandler.cs @@ -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; } diff --git a/test/TestSites/StartupNtlmAuthentication.cs b/test/TestSites/StartupNtlmAuthentication.cs index 42db680d11..bdda8c9dcd 100644 --- a/test/TestSites/StartupNtlmAuthentication.cs +++ b/test/TestSites/StartupNtlmAuthentication.cs @@ -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"))