From 5a2499eb2210f20b7618aedaecff4ddecb7af15a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 16 Jul 2015 12:43:03 -0700 Subject: [PATCH] Rename ExternalAuthenticationOptions => Shared --- samples/OpenIdConnectSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 2 +- .../FacebookAuthenticationMiddleware.cs | 9 ++++++--- .../GoogleAuthenticationMiddleware.cs | 7 +++++-- .../MicrosoftAccountAuthenticationMiddleware.cs | 7 +++++-- .../OAuthAuthenticationMiddleware.cs | 4 ++-- .../OAuthAuthenticationOptions.cs | 2 +- .../OpenIdConnectAuthenticationMiddleware.cs | 9 ++++++--- .../TwitterAuthenticationMiddleware.cs | 12 +++++++----- .../TwitterAuthenticationOptions.cs | 2 +- ...tionOptions.cs => SharedAuthenticationOptions.cs} | 2 +- .../Facebook/FacebookMiddlewareTests.cs | 4 ++-- .../Google/GoogleMiddlewareTests.cs | 2 +- .../MicrosoftAccountMiddlewareTests.cs | 2 +- ...AuthenticationMiddlewareForTestingAuthenticate.cs | 4 ++-- .../OpenIdConnect/OpenIdConnectMiddlewareTests.cs | 2 +- .../Twitter/TwitterMiddlewareTests.cs | 2 +- 17 files changed, 44 insertions(+), 30 deletions(-) rename src/Microsoft.AspNet.Authentication/{ExternalAuthenticationOptions.cs => SharedAuthenticationOptions.cs} (92%) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3023a55aaa..00652c32f5 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -15,7 +15,7 @@ namespace OpenIdConnectSample public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index bce45cb7a9..cad2f0a707 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -22,7 +22,7 @@ namespace CookieSample public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationMiddleware.cs index 1184f4479e..d327f9dca5 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAuthenticationMiddleware.cs @@ -21,19 +21,22 @@ namespace Microsoft.AspNet.Authentication.Facebook /// /// Initializes a new . /// - /// The next middleware in the application pipeline to invoke. + /// The next middleware in the HTTP pipeline to invoke. /// /// + /// + /// /// Configuration options for the middleware. + /// public FacebookAuthenticationMiddleware( [NotNull] RequestDelegate next, [NotNull] IDataProtectionProvider dataProtectionProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions configureOptions = null) - : base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions) + : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions) { if (string.IsNullOrWhiteSpace(Options.AppId)) { diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs index 3f07bc0e9e..b4d6cee923 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAuthenticationMiddleware.cs @@ -24,16 +24,19 @@ namespace Microsoft.AspNet.Authentication.Google /// The next middleware in the HTTP pipeline to invoke. /// /// + /// + /// /// Configuration options for the middleware. + /// public GoogleAuthenticationMiddleware( [NotNull] RequestDelegate next, [NotNull] IDataProtectionProvider dataProtectionProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions configureOptions = null) - : base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions) + : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions) { if (Options.Scope.Count == 0) { diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs index e4f5751703..86da69893a 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAuthenticationMiddleware.cs @@ -22,16 +22,19 @@ namespace Microsoft.AspNet.Authentication.MicrosoftAccount /// The next middleware in the HTTP pipeline to invoke. /// /// + /// + /// /// Configuration options for the middleware. + /// public MicrosoftAccountAuthenticationMiddleware( [NotNull] RequestDelegate next, [NotNull] IDataProtectionProvider dataProtectionProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions configureOptions = null) - : base(next, dataProtectionProvider, loggerFactory, encoder, externalOptions, options, configureOptions) + : base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options, configureOptions) { if (Options.Scope.Count == 0) { diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs index f8a4135fd3..5ac0521f3d 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationMiddleware.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Authentication.OAuth [NotNull] IDataProtectionProvider dataProtectionProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions 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; } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs index 6244de1ef4..2796acfd19 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAuthenticationOptions.cs @@ -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, is used as a fallback value. + /// When omitted, is used as a fallback value. /// public string SignInScheme { get; set; } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs index 7c67f8ef7a..e3a05f58eb 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs @@ -31,6 +31,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// The next middleware in the ASP.NET pipeline to invoke. /// provider for creating a data protector. /// factory for creating a . + /// + /// + /// /// a instance that will supply /// if configureOptions is null. /// a instance that will be passed to an instance of @@ -42,14 +45,14 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, [NotNull] IServiceProvider services, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions 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) diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs index e555e84b24..cc5faba732 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationMiddleware.cs @@ -26,16 +26,18 @@ namespace Microsoft.AspNet.Authentication.Twitter /// Initializes a /// /// The next middleware in the HTTP pipeline to invoke - /// /// /// + /// + /// /// Configuration options for the middleware + /// public TwitterAuthenticationMiddleware( [NotNull] RequestDelegate next, [NotNull] IDataProtectionProvider dataProtectionProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IUrlEncoder encoder, - [NotNull] IOptions externalOptions, + [NotNull] IOptions sharedOptions, [NotNull] IOptions options, ConfigureOptions 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( 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. diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs index ba85b77ba4..f5d40e8809 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAuthenticationOptions.cs @@ -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, is used as a fallback value. + /// 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/SharedAuthenticationOptions.cs similarity index 92% rename from src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs rename to src/Microsoft.AspNet.Authentication/SharedAuthenticationOptions.cs index 19bd05fa92..5a03a279fa 100644 --- a/src/Microsoft.AspNet.Authentication/ExternalAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication/SharedAuthenticationOptions.cs @@ -6,7 +6,7 @@ using System; namespace Microsoft.AspNet.Authentication { - public class ExternalAuthenticationOptions + public class SharedAuthenticationOptions { /// /// Gets or sets the authentication scheme corresponding to the default middleware diff --git a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs index 711c601ba5..285e368e95 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Facebook/FacebookMiddlewareTests.cs @@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Authentication.Facebook options.AuthenticationScheme = "External"; options.AutomaticAuthentication = true; }); - services.Configure(options => + services.Configure(options => { options.SignInScheme = "External"; }); @@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Authentication.Facebook { options.AuthenticationScheme = "External"; }); - services.Configure(options => + services.Configure(options => { options.SignInScheme = "External"; }); diff --git a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs index a37b0f716a..f75a97643a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Google/GoogleMiddlewareTests.cs @@ -601,7 +601,7 @@ namespace Microsoft.AspNet.Authentication.Google services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = TestExtensions.CookieAuthenticationScheme; }); diff --git a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs index 6ef50be516..ee5dcb526a 100644 --- a/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/MicrosoftAccount/MicrosoftAccountMiddlewareTests.cs @@ -218,7 +218,7 @@ namespace Microsoft.AspNet.Authentication.Tests.MicrosoftAccount services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = TestExtensions.CookieAuthenticationScheme; }); diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectAuthenticationMiddlewareForTestingAuthenticate.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectAuthenticationMiddlewareForTestingAuthenticate.cs index b88438e0e6..80a17c12b7 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectAuthenticationMiddlewareForTestingAuthenticate.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectAuthenticationMiddlewareForTestingAuthenticate.cs @@ -26,12 +26,12 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect ILoggerFactory loggerFactory, IUrlEncoder encoder, IServiceProvider services, - IOptions externalOptions, + IOptions sharedOptions, IOptions options, ConfigureOptions 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; diff --git a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs index fc0533f883..7666ac4e39 100644 --- a/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/OpenIdConnect/OpenIdConnectMiddlewareTests.cs @@ -366,7 +366,7 @@ namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); diff --git a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs index eb5b00554d..c5ad93b502 100644 --- a/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Authentication.Test/Twitter/TwitterMiddlewareTests.cs @@ -171,7 +171,7 @@ namespace Microsoft.AspNet.Authentication.Twitter services => { services.AddAuthentication(); - services.Configure(options => + services.Configure(options => { options.SignInScheme = "External"; });