Rename ExternalAuthenticationOptions => Shared

This commit is contained in:
Hao Kung 2015-07-16 12:43:03 -07:00
parent 73d4440a25
commit 5a2499eb22
17 changed files with 44 additions and 30 deletions

View File

@ -15,7 +15,7 @@ namespace OpenIdConnectSample
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});

View File

@ -22,7 +22,7 @@ namespace CookieSample
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});

View File

@ -21,19 +21,22 @@ namespace Microsoft.AspNet.Authentication.Facebook
/// <summary>
/// Initializes a new <see cref="FacebookAuthenticationMiddleware"/>.
/// </summary>
/// <param name="next">The next middleware in the application pipeline to invoke.</param>
/// <param name="next">The next middleware in the HTTP pipeline to invoke.</param>
/// <param name="dataProtectionProvider"></param>
/// <param name="loggerFactory"></param>
/// <param name="encoder"></param>
/// <param name="sharedOptions"></param>
/// <param name="options">Configuration options for the middleware.</param>
/// <param name="configureOptions"></param>
public FacebookAuthenticationMiddleware(
[NotNull] RequestDelegate next,
[NotNull] IDataProtectionProvider dataProtectionProvider,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<FacebookAuthenticationOptions> options,
ConfigureOptions<FacebookAuthenticationOptions> configureOptions = null)
: base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions)
{
if (string.IsNullOrWhiteSpace(Options.AppId))
{

View File

@ -24,16 +24,19 @@ namespace Microsoft.AspNet.Authentication.Google
/// <param name="next">The next middleware in the HTTP pipeline to invoke.</param>
/// <param name="dataProtectionProvider"></param>
/// <param name="loggerFactory"></param>
/// <param name="encoder"></param>
/// <param name="sharedOptions"></param>
/// <param name="options">Configuration options for the middleware.</param>
/// <param name="configureOptions"></param>
public GoogleAuthenticationMiddleware(
[NotNull] RequestDelegate next,
[NotNull] IDataProtectionProvider dataProtectionProvider,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<GoogleAuthenticationOptions> options,
ConfigureOptions<GoogleAuthenticationOptions> configureOptions = null)
: base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions)
{
if (Options.Scope.Count == 0)
{

View File

@ -22,16 +22,19 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount
/// <param name="next">The next middleware in the HTTP pipeline to invoke.</param>
/// <param name="dataProtectionProvider"></param>
/// <param name="loggerFactory"></param>
/// <param name="encoder"></param>
/// <param name="sharedOptions"></param>
/// <param name="options">Configuration options for the middleware.</param>
/// <param name="configureOptions"></param>
public MicrosoftAccountAuthenticationMiddleware(
[NotNull] RequestDelegate next,
[NotNull] IDataProtectionProvider dataProtectionProvider,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<MicrosoftAccountAuthenticationOptions> options,
ConfigureOptions<MicrosoftAccountAuthenticationOptions> configureOptions = null)
: base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions)
{
if (Options.Scope.Count == 0)
{

View File

@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
[NotNull] IDataProtectionProvider dataProtectionProvider,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<TOptions> options,
ConfigureOptions<TOptions> configureOptions = null)
: base(next, options, loggerFactory, encoder, configureOptions)
@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
if (string.IsNullOrEmpty(Options.SignInScheme))
{
Options.SignInScheme = externalOptions.Options.SignInScheme;
Options.SignInScheme = sharedOptions.Options.SignInScheme;
}
}

View File

@ -100,7 +100,7 @@ namespace Microsoft.AspNet.Authentication.OAuth
/// 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.
/// When omitted, <see cref="SharedAuthenticationOptions.SignInScheme"/> is used as a fallback value.
/// </summary>
public string SignInScheme { get; set; }

View File

@ -31,6 +31,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
/// <param name="next">The next middleware in the ASP.NET pipeline to invoke.</param>
/// <param name="dataProtectionProvider"> provider for creating a data protector.</param>
/// <param name="loggerFactory">factory for creating a <see cref="ILogger"/>.</param>
/// <param name="encoder"></param>
/// <param name="services"></param>
/// <param name="sharedOptions"></param>
/// <param name="options">a <see cref="IOptions{OpenIdConnectAuthenticationOptions}"/> instance that will supply <see cref="OpenIdConnectAuthenticationOptions"/>
/// if configureOptions is null.</param>
/// <param name="configureOptions">a <see cref="ConfigureOptions{OpenIdConnectAuthenticationOptions}"/> instance that will be passed to an instance of <see cref="OpenIdConnectAuthenticationOptions"/>
@ -42,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IServiceProvider services,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<OpenIdConnectAuthenticationOptions> options,
ConfigureOptions<OpenIdConnectAuthenticationOptions> configureOptions = null)
: base(next, options, loggerFactory, encoder, configureOptions)
{
if (string.IsNullOrEmpty(Options.SignInScheme) && !string.IsNullOrEmpty(externalOptions.Options.SignInScheme))
if (string.IsNullOrEmpty(Options.SignInScheme) && !string.IsNullOrEmpty(sharedOptions.Options.SignInScheme))
{
Options.SignInScheme = externalOptions.Options.SignInScheme;
Options.SignInScheme = sharedOptions.Options.SignInScheme;
}
if (Options.StateDataFormat == null)

View File

@ -26,16 +26,18 @@ namespace Microsoft.AspNet.Authentication.Twitter
/// Initializes a <see cref="TwitterAuthenticationMiddleware"/>
/// </summary>
/// <param name="next">The next middleware in the HTTP pipeline to invoke</param>
/// <param name="services"></param>
/// <param name="dataProtectionProvider"></param>
/// <param name="loggerFactory"></param>
/// <param name="encoder"></param>
/// <param name="sharedOptions"></param>
/// <param name="options">Configuration options for the middleware</param>
/// <param name="configureOptions"></param>
public TwitterAuthenticationMiddleware(
[NotNull] RequestDelegate next,
[NotNull] IDataProtectionProvider dataProtectionProvider,
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IUrlEncoder encoder,
[NotNull] IOptions<ExternalAuthenticationOptions> externalOptions,
[NotNull] IOptions<SharedAuthenticationOptions> sharedOptions,
[NotNull] IOptions<TwitterAuthenticationOptions> options,
ConfigureOptions<TwitterAuthenticationOptions> configureOptions = null)
: base(next, options, loggerFactory, encoder, configureOptions)
@ -55,7 +57,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
}
if (Options.StateDataFormat == null)
{
IDataProtector dataProtector = dataProtectionProvider.CreateProtector(
var dataProtector = dataProtectionProvider.CreateProtector(
typeof(TwitterAuthenticationMiddleware).FullName, Options.AuthenticationScheme, "v1");
Options.StateDataFormat = new SecureDataFormat<RequestToken>(
Serializers.RequestToken,
@ -65,7 +67,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
if (string.IsNullOrEmpty(Options.SignInScheme))
{
Options.SignInScheme = externalOptions.Options.SignInScheme;
Options.SignInScheme = sharedOptions.Options.SignInScheme;
}
if (string.IsNullOrEmpty(Options.SignInScheme))
{
@ -92,7 +94,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Managed by caller")]
private static HttpMessageHandler ResolveHttpMessageHandler(TwitterAuthenticationOptions options)
{
HttpMessageHandler handler = options.BackchannelHttpHandler ??
var handler = options.BackchannelHttpHandler ??
#if DNX451
new WebRequestHandler();
// If they provided a validator, apply it or fail.

View File

@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
/// 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.
/// When omitted, <see cref="SharedAuthenticationOptions.SignInScheme"/> is used as a fallback value.
/// </summary>
public string SignInScheme { get; set; }

View File

@ -6,7 +6,7 @@ using System;
namespace Microsoft.AspNet.Authentication
{
public class ExternalAuthenticationOptions
public class SharedAuthenticationOptions
{
/// <summary>
/// Gets or sets the authentication scheme corresponding to the default middleware

View File

@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
options.AuthenticationScheme = "External";
options.AutomaticAuthentication = true;
});
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = "External";
});
@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Authentication.Facebook
{
options.AuthenticationScheme = "External";
});
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = "External";
});

View File

@ -601,7 +601,7 @@ namespace Microsoft.AspNet.Authentication.Google
services =>
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = TestExtensions.CookieAuthenticationScheme;
});

View File

@ -218,7 +218,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount
services =>
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = TestExtensions.CookieAuthenticationScheme;
});

View File

@ -26,12 +26,12 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
ILoggerFactory loggerFactory,
IUrlEncoder encoder,
IServiceProvider services,
IOptions<ExternalAuthenticationOptions> externalOptions,
IOptions<SharedAuthenticationOptions> sharedOptions,
IOptions<OpenIdConnectAuthenticationOptions> options,
ConfigureOptions<OpenIdConnectAuthenticationOptions> configureOptions = null,
OpenIdConnectAuthenticationHandler handler = null
)
: base(next, dataProtectionProvider, loggerFactory, encoder, services, externalOptions, options, configureOptions)
: base(next, dataProtectionProvider, loggerFactory, encoder, services, sharedOptions, options, configureOptions)
{
_handler = handler;
var customFactory = loggerFactory as InMemoryLoggerFactory;

View File

@ -366,7 +366,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
services =>
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});

View File

@ -171,7 +171,7 @@ namespace Microsoft.AspNet.Authentication.Twitter
services =>
{
services.AddAuthentication();
services.Configure<ExternalAuthenticationOptions>(options =>
services.Configure<SharedAuthenticationOptions>(options =>
{
options.SignInScheme = "External";
});