Fix incorrect handler delegation and update SignInScheme documentation

This commit is contained in:
Pinpoint 2015-03-03 16:13:45 +01:00
parent 4a2a742ad5
commit 5e03a6c1ad
6 changed files with 28 additions and 13 deletions

View File

@ -99,7 +99,10 @@ namespace Microsoft.AspNet.Authentication.OAuth
public PathString CallbackPath { get; set; } public PathString CallbackPath { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user <see cref="System.Security.Claims.ClaimsIdentity"/>. /// 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, <see cref="ExternalAuthenticationOptions.SignInScheme"/> is used as a fallback value.
/// </summary> /// </summary>
public string SignInScheme { get; set; } public string SignInScheme { get; set; }

View File

@ -585,4 +585,4 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
return false; return false;
} }
} }
} }

View File

@ -7,12 +7,12 @@ using System.Diagnostics.CodeAnalysis;
using System.IdentityModel.Tokens; using System.IdentityModel.Tokens;
using System.Net.Http; using System.Net.Http;
using System.Text; 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;
using Microsoft.AspNet.Authentication.DataHandler.Encoder; using Microsoft.AspNet.Authentication.DataHandler.Encoder;
using Microsoft.AspNet.Authentication.DataHandler.Serializer; 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.Logging;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols;
@ -45,9 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
{ {
_logger = loggerFactory.CreateLogger<OpenIdConnectAuthenticationMiddleware>(); _logger = loggerFactory.CreateLogger<OpenIdConnectAuthenticationMiddleware>();
if (string.IsNullOrEmpty(Options.SignInScheme))
{
Options.SignInScheme = externalOptions.Options.SignInScheme;
}
if (string.IsNullOrWhiteSpace(Options.TokenValidationParameters.AuthenticationType)) if (string.IsNullOrWhiteSpace(Options.TokenValidationParameters.AuthenticationType))
{ {
Options.TokenValidationParameters.AuthenticationType = externalOptions.Options.SignInScheme; Options.TokenValidationParameters.AuthenticationType = Options.AuthenticationScheme;
} }
if (Options.StateDataFormat == null) if (Options.StateDataFormat == null)

View File

@ -233,13 +233,12 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
public string Scope { get; set; } public string Scope { get; set; }
/// <summary> /// <summary>
/// Gets or sets the AuthenticationScheme used when creating the <see cref="System.Security.Claims.ClaimsIdentity"/>. /// 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, <see cref="ExternalAuthenticationOptions.SignInScheme"/> is used as a fallback value.
/// </summary> /// </summary>
public string SignInScheme public string SignInScheme { get; set; }
{
get { return TokenValidationParameters.AuthenticationType; }
set { TokenValidationParameters.AuthenticationType = value; }
}
/// <summary> /// <summary>
/// Gets or sets the type used to secure data handled by the middleware. /// Gets or sets the type used to secure data handled by the middleware.

View File

@ -89,7 +89,10 @@ namespace Microsoft.AspNet.Authentication.Twitter
public PathString CallbackPath { get; set; } public PathString CallbackPath { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user <see cref="System.Security.Claims.ClaimsIdentity"/>. /// 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, <see cref="ExternalAuthenticationOptions.SignInScheme"/> is used as a fallback value.
/// </summary> /// </summary>
public string SignInScheme { get; set; } public string SignInScheme { get; set; }

View File

@ -8,6 +8,11 @@ namespace Microsoft.AspNet.Authentication
{ {
public class ExternalAuthenticationOptions public class ExternalAuthenticationOptions
{ {
/// <summary>
/// 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.
/// </summary>
public string SignInScheme { get; set; } public string SignInScheme { get; set; }
} }
} }