From 5e03a6c1ad2d94a1e6c4757e0931d199761942a8 Mon Sep 17 00:00:00 2001 From: Pinpoint Date: Tue, 3 Mar 2015 16:13:45 +0100 Subject: [PATCH] Fix incorrect handler delegation and update SignInScheme documentation --- .../OAuthAuthenticationOptions.cs | 5 ++++- ...ler.cs => OpenIdConnectAuthenticationHandler.cs} | 2 +- .../OpenIdConnectAuthenticationMiddleware.cs | 13 +++++++++---- .../OpenIdConnectAuthenticationOptions.cs | 11 +++++------ .../TwitterAuthenticationOptions.cs | 5 ++++- .../ExternalAuthenticationOptions.cs | 5 +++++ 6 files changed, 28 insertions(+), 13 deletions(-) rename src/Microsoft.AspNet.Authentication.OpenIdConnect/{OpenidConnectAuthenticationHandler.cs => OpenIdConnectAuthenticationHandler.cs} (99%) diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs index 3dda288129..bd9ab43b06 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs @@ -99,7 +99,10 @@ namespace Microsoft.AspNet.Authentication.OAuth public PathString CallbackPath { get; set; } /// - /// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user . + /// Gets or sets the authentication scheme corresponding to the middleware + /// responsible of persisting user's identity after a successful authentication. + /// This value typically corresponds to a cookie middleware registered in the Startup class. + /// When omitted, is used as a fallback value. /// public string SignInScheme { get; set; } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs similarity index 99% rename from src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs rename to src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs index 6a629045b8..32f7a69c0f 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenidConnectAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs @@ -585,4 +585,4 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect return false; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs index 53284a50e9..e58b7fff85 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs @@ -7,12 +7,12 @@ using System.Diagnostics.CodeAnalysis; using System.IdentityModel.Tokens; using System.Net.Http; using System.Text; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.DataProtection; -using Microsoft.AspNet.Http; using Microsoft.AspNet.Authentication.DataHandler; using Microsoft.AspNet.Authentication.DataHandler.Encoder; using Microsoft.AspNet.Authentication.DataHandler.Serializer; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.DataProtection; +using Microsoft.AspNet.Http; using Microsoft.Framework.Logging; using Microsoft.Framework.OptionsModel; using Microsoft.IdentityModel.Protocols; @@ -45,9 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { _logger = loggerFactory.CreateLogger(); + if (string.IsNullOrEmpty(Options.SignInScheme)) + { + Options.SignInScheme = externalOptions.Options.SignInScheme; + } + if (string.IsNullOrWhiteSpace(Options.TokenValidationParameters.AuthenticationType)) { - Options.TokenValidationParameters.AuthenticationType = externalOptions.Options.SignInScheme; + Options.TokenValidationParameters.AuthenticationType = Options.AuthenticationScheme; } if (Options.StateDataFormat == null) diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs index 25b70473a8..f7bfde804b 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs @@ -233,13 +233,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect public string Scope { get; set; } /// - /// Gets or sets the AuthenticationScheme used when creating the . + /// Gets or sets the authentication scheme corresponding to the middleware + /// responsible of persisting user's identity after a successful authentication. + /// This value typically corresponds to a cookie middleware registered in the Startup class. + /// When omitted, is used as a fallback value. /// - public string SignInScheme - { - get { return TokenValidationParameters.AuthenticationType; } - set { TokenValidationParameters.AuthenticationType = value; } - } + public string SignInScheme { get; set; } /// /// Gets or sets the type used to secure data handled by the middleware. diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs index d17daa0e9e..a3179c3867 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs @@ -89,7 +89,10 @@ namespace Microsoft.AspNet.Authentication.Twitter public PathString CallbackPath { get; set; } /// - /// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user . + /// Gets or sets the authentication scheme corresponding to the middleware + /// responsible of persisting user's identity after a successful authentication. + /// This value typically corresponds to a cookie middleware registered in the Startup class. + /// When omitted, is used as a fallback value. /// public string SignInScheme { get; set; } diff --git a/src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs index 966e2cfe14..a80b80b83f 100644 --- a/src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs @@ -8,6 +8,11 @@ namespace Microsoft.AspNet.Authentication { public class ExternalAuthenticationOptions { + /// + /// Gets or sets the authentication scheme corresponding to the default middleware + /// responsible of persisting user's identity after a successful authentication. + /// This value typically corresponds to a cookie middleware registered in the Startup class. + /// public string SignInScheme { get; set; } } }