From 84dfcf5258b12607656edae79fd4dcf9802a3b05 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 14 Oct 2014 19:14:54 -0700 Subject: [PATCH] React to Options and Hosting changes --- samples/CookieSample/Startup.cs | 2 +- samples/CookieSessionSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 2 +- .../CookieAuthenticationExtensions.cs | 4 ++-- .../CookieAuthenticationMiddleware.cs | 4 ++-- .../FacebookAuthenticationExtensions.cs | 4 ++-- .../FacebookAuthenticationMiddleware.cs | 6 +++--- .../GoogleAuthenticationExtensions.cs | 4 ++-- .../GoogleAuthenticationMiddleware.cs | 6 +++--- .../MicrosoftAccountAuthenticationExtensions.cs | 4 ++-- .../MicrosoftAccountAuthenticationMiddleware.cs | 6 +++--- .../OAuthAuthenticationExtensions.cs | 2 +- .../OAuthAuthenticationMiddleware.cs | 6 +++--- .../OAuthBearerAuthenticationExtensions.cs | 2 +- .../OAuthBearerAuthenticationMiddleware.cs | 4 ++-- .../TwitterAuthenticationExtensions.cs | 4 ++-- .../TwitterAuthenticationMiddleware.cs | 6 +++--- .../Infrastructure/AuthenticationMiddleware.cs | 4 ++-- .../Cookies/CookieMiddlewareTests.cs | 2 +- .../Facebook/FacebookMiddlewareTests.cs | 8 ++++---- .../Google/GoogleMiddlewareTests.cs | 4 ++-- .../MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs | 4 ++-- .../Twitter/TwitterMiddlewareTests.cs | 4 ++-- 23 files changed, 47 insertions(+), 47 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 48c05fb7d6..fc78aec37d 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -9,7 +9,7 @@ namespace CookieSample { public void Configure(IApplicationBuilder app) { - app.UsePerRequestServices(services => { }); + app.UseServices(services => { }); app.UseCookieAuthentication(options => { }); diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 7772a392e6..a4217e6d2b 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -10,7 +10,7 @@ namespace CookieSessionSample { public void Configure(IApplicationBuilder app) { - app.UsePerRequestServices(services => { }); + app.UseServices(services => { }); app.UseCookieAuthentication(options => { options.SessionStore = new MemoryCacheSessionStore(); diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 1836cc02ae..18f17ac0f7 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -24,7 +24,7 @@ namespace CookieSample { app.UseErrorPage(); - app.UsePerRequestServices(services => + app.UseServices(services => { services.ConfigureOptions(options => { diff --git a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs index 98d39cca71..191d44da82 100644 --- a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder { public static IServiceCollection ConfigureCookieAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) { - return services.ConfigureOptions(configure); + return services.Configure(configure); } /// @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Builder public static IApplicationBuilder UseCookieAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs index fff6906658..087820e295 100644 --- a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationMiddleware.cs @@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Security.Cookies public CookieAuthenticationMiddleware(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor options, - IOptionsAction configureOptions) + IOptions options, + ConfigureOptions configureOptions) : base(next, options, configureOptions) { if (Options.Notifications == null) diff --git a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationExtensions.cs index aa59e2efee..51c5eac0e8 100644 --- a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder { public static IServiceCollection ConfigureFacebookAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) { - return services.ConfigureOptions(configure); + return services.Configure(configure); } /// @@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Builder public static IApplicationBuilder UseFacebookAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationMiddleware.cs index a453e085a0..b7891d139d 100644 --- a/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.Facebook/FacebookAuthenticationMiddleware.cs @@ -28,9 +28,9 @@ namespace Microsoft.AspNet.Security.Facebook RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor externalOptions, - IOptionsAccessor options, - IOptionsAction configureOptions = null) + IOptions externalOptions, + IOptions options, + ConfigureOptions configureOptions = null) : base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions) { if (string.IsNullOrWhiteSpace(Options.AppId)) diff --git a/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationExtensions.cs index 7bb4a24e25..474df5e322 100644 --- a/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder { public static IServiceCollection ConfigureGoogleAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) { - return services.ConfigureOptions(configure); + return services.Configure(configure); } /// @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Builder public static IApplicationBuilder UseGoogleAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationMiddleware.cs index 66cef2e2a0..51072c65c4 100644 --- a/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.Google/GoogleAuthenticationMiddleware.cs @@ -32,9 +32,9 @@ namespace Microsoft.AspNet.Security.Google RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor externalOptions, - IOptionsAccessor options, - IOptionsAction configureOptions = null) + IOptions externalOptions, + IOptions options, + ConfigureOptions configureOptions = null) : base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions) { if (Options.Notifications == null) diff --git a/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationExtensions.cs index 64ec369ab5..912271da61 100644 --- a/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationExtensions.cs @@ -15,13 +15,13 @@ namespace Microsoft.AspNet.Builder { public static IServiceCollection ConfigureMicrosoftAccountAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) { - return services.ConfigureOptions(configure); + return services.Configure(configure); } public static IApplicationBuilder UseMicrosoftAccountAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs index c36ad16de2..26c80bac4b 100644 --- a/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs @@ -28,9 +28,9 @@ namespace Microsoft.AspNet.Security.MicrosoftAccount RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor externalOptions, - IOptionsAccessor options, - IOptionsAction configureOptions = null) + IOptions externalOptions, + IOptions options, + ConfigureOptions configureOptions = null) : base(next, dataProtectionProvider, loggerFactory, externalOptions, options, configureOptions) { if (Options.Notifications == null) diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationExtensions.cs index bdbc3c9ee5..55ac54ca65 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationExtensions.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder public static IApplicationBuilder UseOAuthAuthentication([NotNull] this IApplicationBuilder app, [NotNull] string authenticationType, Action> configureOptions = null) { return app.UseMiddleware, IOAuthAuthenticationNotifications>>( - new OptionsAction>(options => + new ConfigureOptions>(options => { options.AuthenticationType = authenticationType; options.Caption = authenticationType; diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationMiddleware.cs index e3d65c55bd..23160b0532 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthAuthenticationMiddleware.cs @@ -33,9 +33,9 @@ namespace Microsoft.AspNet.Security.OAuth RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor externalOptions, - IOptionsAccessor options, - IOptionsAction configureOptions = null) + IOptions externalOptions, + IOptions options, + ConfigureOptions configureOptions = null) : base(next, options, configureOptions) { // todo: review error handling diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationExtensions.cs index 118598120e..b5512d01cd 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationExtensions.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Builder public static IApplicationBuilder UseOAuthBearerAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationMiddleware.cs index 715d43b13f..8993e107cd 100644 --- a/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.OAuth/OAuthBearerAuthenticationMiddleware.cs @@ -30,8 +30,8 @@ namespace Microsoft.AspNet.Security.OAuth RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor options, - IOptionsAction configureOptions) + IOptions options, + ConfigureOptions configureOptions) : base(next, options, configureOptions) { _logger = loggerFactory.Create(); diff --git a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationExtensions.cs index 9f2c54ce1f..5e97d82245 100644 --- a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationExtensions.cs @@ -16,13 +16,13 @@ namespace Microsoft.AspNet.Builder { public static IServiceCollection ConfigureTwitterAuthentication([NotNull] this IServiceCollection services, [NotNull] Action configure) { - return services.ConfigureOptions(configure); + return services.Configure(configure); } public static IApplicationBuilder UseTwitterAuthentication([NotNull] this IApplicationBuilder app, Action configureOptions = null, string optionsName = "") { return app.UseMiddleware( - new OptionsAction(configureOptions ?? (o => { })) + new ConfigureOptions(configureOptions ?? (o => { })) { Name = optionsName }); diff --git a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationMiddleware.cs index ffa9b9bb69..7ca77a9c1f 100644 --- a/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security.Twitter/TwitterAuthenticationMiddleware.cs @@ -36,9 +36,9 @@ namespace Microsoft.AspNet.Security.Twitter RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, - IOptionsAccessor externalOptions, - IOptionsAccessor options, - IOptionsAction configureOptions = null) + IOptions externalOptions, + IOptions options, + ConfigureOptions configureOptions = null) : base(next, options, configureOptions) { if (string.IsNullOrWhiteSpace(Options.ConsumerSecret)) diff --git a/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationMiddleware.cs b/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationMiddleware.cs index 1ea787fce8..86c2fb921f 100644 --- a/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Security/Infrastructure/AuthenticationMiddleware.cs @@ -14,12 +14,12 @@ namespace Microsoft.AspNet.Security.Infrastructure { private readonly RequestDelegate _next; - protected AuthenticationMiddleware([NotNull] RequestDelegate next, [NotNull] IOptionsAccessor options, IOptionsAction configureOptions) + protected AuthenticationMiddleware([NotNull] RequestDelegate next, [NotNull] IOptions options, ConfigureOptions configureOptions) { if (configureOptions != null) { Options = options.GetNamedOptions(configureOptions.Name); - configureOptions.Invoke(Options); + configureOptions.Configure(Options, configureOptions.Name); } else { diff --git a/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs index 63b2c0f72d..a02dc14752 100644 --- a/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Cookies/CookieMiddlewareTests.cs @@ -369,7 +369,7 @@ namespace Microsoft.AspNet.Security.Cookies { return TestServer.Create(app => { - app.UsePerRequestServices(services => { }); + app.UseServices(services => { }); app.UseCookieAuthentication(configureOptions); app.Use(async (context, next) => { diff --git a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs index 5e78bccda4..f3e0bf703b 100644 --- a/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Facebook/FacebookMiddlewareTests.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Security.Facebook var server = CreateServer( app => { - app.UsePerRequestServices(services => + app.UseServices(services => { services.ConfigureFacebookAuthentication(options => { @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Security.Facebook { options.AuthenticationType = "External"; }); - services.ConfigureOptions(options => + services.Configure(options => { options.SignInAsAuthenticationType = "External"; }); @@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Security.Facebook var server = CreateServer( app => { - app.UsePerRequestServices(services => + app.UseServices(services => { services.ConfigureFacebookAuthentication(options => { @@ -81,7 +81,7 @@ namespace Microsoft.AspNet.Security.Facebook { options.AuthenticationType = "External"; }); - services.ConfigureOptions(options => + services.Configure(options => { options.SignInAsAuthenticationType = "External"; }); diff --git a/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs index 564935496c..3a1113d7f8 100644 --- a/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Google/GoogleMiddlewareTests.cs @@ -465,9 +465,9 @@ namespace Microsoft.AspNet.Security.Google { return TestServer.Create(app => { - app.UsePerRequestServices(services => + app.UseServices(services => { - services.ConfigureOptions(options => + services.Configure(options => { options.SignInAsAuthenticationType = CookieAuthenticationType; }); diff --git a/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index c42ec18513..d055df748c 100644 --- a/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -163,9 +163,9 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount { return TestServer.Create(app => { - app.UsePerRequestServices(services => + app.UseServices(services => { - services.ConfigureOptions(options => + services.Configure(options => { options.SignInAsAuthenticationType = "External"; }); diff --git a/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs index e9b54e4bc3..5505f97542 100644 --- a/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Security.Test/Twitter/TwitterMiddlewareTests.cs @@ -109,9 +109,9 @@ namespace Microsoft.AspNet.Security.Twitter { return TestServer.Create(app => { - app.UsePerRequestServices(services => + app.UseServices(services => { - services.ConfigureOptions(options => + services.Configure(options => { options.SignInAsAuthenticationType = "External"; });