Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Commit 5753784

Browse files
committed
#391 Add back the DisplayName setting
1 parent 550cc03 commit 5753784

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

samples/IISSample/Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Linq;
3+
using Microsoft.AspNetCore.Authentication;
34
using Microsoft.AspNetCore.Builder;
45
using Microsoft.AspNetCore.Hosting;
56
using Microsoft.AspNetCore.Http;
7+
using Microsoft.AspNetCore.Server.IISIntegration;
68
using Microsoft.Extensions.DependencyInjection;
79
using Microsoft.Extensions.Logging;
810

@@ -15,13 +17,14 @@ public void ConfigureServices(IServiceCollection services)
1517
// These two middleware are registered via an IStartupFilter in UseIISIntegration but you can configure them here.
1618
services.Configure<IISOptions>(options =>
1719
{
20+
options.AuthenticationDisplayName = "Windows Auth";
1821
});
1922
services.Configure<ForwardedHeadersOptions>(options =>
2023
{
2124
});
2225
}
2326

24-
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
27+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory, IAuthenticationSchemeProvider authSchemeProvider)
2528
{
2629
var logger = loggerfactory.CreateLogger("Requests");
2730

@@ -50,6 +53,8 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
5053
await context.Response.WriteAsync(Environment.NewLine);
5154

5255
await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
56+
var scheme = await authSchemeProvider.GetSchemeAsync(IISDefaults.AuthenticationScheme);
57+
await context.Response.WriteAsync("DisplayName: " + scheme?.DisplayName + Environment.NewLine);
5358
await context.Response.WriteAsync(Environment.NewLine);
5459

5560
await context.Response.WriteAsync("Headers:" + Environment.NewLine);

src/Microsoft.AspNetCore.Server.IISIntegration/IISMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public IISMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IOption
5757

5858
if (_options.ForwardWindowsAuthentication)
5959
{
60-
authentication.AddScheme(new AuthenticationScheme(IISDefaults.AuthenticationScheme, displayName: null, handlerType: typeof(AuthenticationHandler)));
60+
authentication.AddScheme(new AuthenticationScheme(IISDefaults.AuthenticationScheme, _options.AuthenticationDisplayName, typeof(AuthenticationHandler)));
6161
}
6262

6363
_pairingToken = pairingToken;

src/Microsoft.AspNetCore.Server.IISIntegration/IISOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class IISOptions
1212
/// </summary>
1313
public bool AutomaticAuthentication { get; set; } = true;
1414

15+
/// <summary>
16+
/// Sets the display name shown to users on login pages. The default is null.
17+
/// </summary>
18+
public string AuthenticationDisplayName { get; set; }
19+
1520
/// <summary>
1621
/// Used to indicate if the authentication handler should be registered. This is only done if ANCM indicates
1722
/// IIS has a non-anonymous authentication enabled, or for back compat with ANCMs that did not provide this information.

0 commit comments

Comments
 (0)