From db9ae6263233e1d95245cb911614d0e20a12edfa Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 2 Jun 2017 14:28:03 -0700 Subject: [PATCH] IInitializeOptions => IPostConfigureOptions --- ...s => CookieAuthenticationPostConfigureOptions.cs} | 12 ++++++------ .../CookieExtensions.cs | 2 +- .../FacebookExtensions.cs | 1 + .../{ => Internal}/FacebookConfigureOptions.cs | 4 ++-- .../GoogleExtensions.cs | 1 + .../{ => Internal}/GoogleConfigureOptions.cs | 4 ++-- .../{ => Internal}/JwtBearerConfigureOptions.cs | 4 ++-- .../JwtBearerExtensions.cs | 3 ++- ...itializer.cs => JwtBearerPostConfigureOptions.cs} | 10 +++++----- .../MicrosoftAccountConfigureOptions.cs | 4 ++-- .../MicrosoftAccountExtensions.cs | 1 + .../OAuthExtensions.cs | 2 +- ...thInitializer.cs => OAuthPostConfigureOptions.cs} | 6 +++--- .../{ => Internal}/OpenIdConnectConfigureOptions.cs | 2 +- .../OpenIdConnectExtensions.cs | 3 ++- ...lizer.cs => OpenIdConnectPostConfigureOptions.cs} | 12 ++++++------ .../{ => Internal}/TwitterConfigureOptions.cs | 4 ++-- .../TwitterExtensions.cs | 3 ++- ...Initializer.cs => TwitterPostConfigureOptions.cs} | 12 ++++++------ .../AuthenticationSchemeOptions.cs | 9 --------- .../AuthenticationServiceCollectionExtensions.cs | 8 +++----- 21 files changed, 51 insertions(+), 56 deletions(-) rename src/Microsoft.AspNetCore.Authentication.Cookies/{CookieAuthenticationInitializer.cs => CookieAuthenticationPostConfigureOptions.cs} (81%) rename src/Microsoft.AspNetCore.Authentication.Facebook/{ => Internal}/FacebookConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.Google/{ => Internal}/GoogleConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{ => Internal}/JwtBearerConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{JwtBearerInitializer.cs => JwtBearerPostConfigureOptions.cs} (89%) rename src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/{ => Internal}/MicrosoftAccountConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.OAuth/{OAuthInitializer.cs => OAuthPostConfigureOptions.cs} (86%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{ => Internal}/OpenIdConnectConfigureOptions.cs (91%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{OpenIdConnectInitializer.cs => OpenIdConnectPostConfigureOptions.cs} (91%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{ => Internal}/TwitterConfigureOptions.cs (80%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{TwitterInitializer.cs => TwitterPostConfigureOptions.cs} (81%) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs index af4a85b191..38211e0f19 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Used to setup defaults for all . /// - public class CookieAuthenticationInitializer : IInitializeOptions + public class PostConfigureCookieAuthenticationOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public CookieAuthenticationInitializer(IDataProtectionProvider dataProtection) + public PostConfigureCookieAuthenticationOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, CookieAuthenticationOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, CookieAuthenticationOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index b528dec9cb..6f23abcc4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, CookieAuthenticationInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 1bb065414d..7d6fb84421 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; +using Microsoft.AspNetCore.Authentication.Facebook.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs index 887789ebf1..df1ab710bd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook.Internal { - internal class FacebookConfigureOptions : ConfigureDefaultOptions + public class FacebookConfigureOptions : ConfigureDefaultOptions { public FacebookConfigureOptions(IConfiguration config) : base(FacebookDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index c11b155d9c..07d3e16d61 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.Google.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs index 1041f1eec5..bbc5e208a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google.Internal { - internal class GoogleConfigureOptions : ConfigureDefaultOptions + public class GoogleConfigureOptions : ConfigureDefaultOptions { public GoogleConfigureOptions(IConfiguration config) : base(GoogleDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs index d26bf66711..5c1e931f40 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal { - internal class JwtBearerConfigureOptions : ConfigureDefaultOptions + public class JwtBearerConfigureOptions : ConfigureDefaultOptions { // Bind to "Bearer" section by default public JwtBearerConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 0bd3a9400c..134e99920b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authentication.JwtBearer.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs similarity index 89% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs index 0aeed11832..8829bfac0f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs @@ -12,14 +12,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Used to setup defaults for all . /// - public class JwtBearerInitializer : IInitializeOptions + public class JwtBearerPostConfigureOptions : IPostConfigureOptions { /// - /// Invoked to initialize a JwtBearerOptions instance. + /// Invoked to post configure a JwtBearerOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, JwtBearerOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, JwtBearerOptions options) { if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.Audience)) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs index b0be3de977..60591e1e4a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal { - internal class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions + public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions { // Bind to "Microsoft" section by default public MicrosoftAccountConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 1a7fee370f..ff743c9728 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 257aed9cb1..4ad0a83362 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.DependencyInjection where TOptions : OAuthOptions, new() where THandler : OAuthHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs similarity index 86% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs index 99f65253a8..e97346413c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs @@ -12,18 +12,18 @@ namespace Microsoft.Extensions.DependencyInjection /// /// Used to setup defaults for the OAuthOptions. /// - public class OAuthInitializer : IInitializeOptions + public class OAuthPostConfigureOptions : IPostConfigureOptions where TOptions : OAuthOptions, new() where THandler : OAuthHandler { private readonly IDataProtectionProvider _dp; - public OAuthInitializer(IDataProtectionProvider dataProtection) + public OAuthPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; if (options.Backchannel == null) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs index 1a6450b7b2..c395185151 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal { internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index b4ac4b9fb7..6c965f047c 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs index 7421af9c0a..b79f1d1edf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs @@ -14,21 +14,21 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Used to setup defaults for all . /// - public class OpenIdConnectInitializer : IInitializeOptions + public class OpenIdConnectPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public OpenIdConnectInitializer(IDataProtectionProvider dataProtection) + public OpenIdConnectPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, OpenIdConnectOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, OpenIdConnectOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs similarity index 80% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs index 03d7ae8092..62982fa19a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter.Internal { - internal class TwitterConfigureOptions : ConfigureDefaultOptions + public class TwitterConfigureOptions : ConfigureDefaultOptions { // Bind to "Twitter" section by default public TwitterConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 11586f9844..dac9ee3512 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.Authentication.Twitter.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs index 08e9c5b832..09db5699f9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Used to setup defaults for all . /// - public class TwitterInitializer : IInitializeOptions + public class TwitterPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public TwitterInitializer(IDataProtectionProvider dataProtection) + public TwitterPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, TwitterOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, TwitterOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 55bc09d8ae..0e86b3a9ff 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,18 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - public class InitializeAuthenticationSchemeOptions : InitializeOptions - where TOptions : AuthenticationSchemeOptions - { - public InitializeAuthenticationSchemeOptions(string name) - : base(name, options => options.ClaimsIssuer = options.ClaimsIssuer ?? name) - { } - } - /// /// Contains the options used by the . /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index ff367f5557..7ebc979f1b 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -79,12 +77,12 @@ namespace Microsoft.Extensions.DependencyInjection where TOptions : RemoteAuthenticationOptions, new() where THandler : RemoteAuthenticationHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } // Used to ensure that there's always a default data protection provider - private class EnsureSignInScheme : IInitializeOptions where TOptions : RemoteAuthenticationOptions + private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; @@ -93,7 +91,7 @@ namespace Microsoft.Extensions.DependencyInjection _authOptions = authOptions.Value; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; }