From 2d21b72561c1c7092ee7eb389dee0dff1cf45b79 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 23 Dec 2015 15:26:41 -0800 Subject: [PATCH] Adding back middleware initialization with options instance. --- .../CookieAppBuilderExtensions.cs | 20 ++++++++++++++ .../FacebookAppBuilderExtensions.cs | 20 ++++++++++++++ .../GoogleAppBuilderExtensions.cs | 20 ++++++++++++++ .../JwtBearerAppBuilderExtensions.cs | 26 +++++++++++++++++++ .../MicrosoftAccountAppBuilderExtensions.cs | 20 ++++++++++++++ .../OAuthAppBuilderExtensions.cs | 20 ++++++++++++++ .../OpenIdConnectAppBuilderExtensions.cs | 20 ++++++++++++++ .../TwitterAppBuilderExtensions.cs | 22 +++++++++++++++- ...laimsTransformationAppBuilderExtensions.cs | 20 ++++++++++++++ .../CookiePolicyAppBuilderExtensions.cs | 20 ++++++++++++++ 10 files changed, 207 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs index 46539f875c..f990df58aa 100644 --- a/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -48,5 +48,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables cookie authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs index cc9b73f48b..f649790a1a 100644 --- a/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Facebook authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs index 88e56928f8..34f65b112e 100644 --- a/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Google authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 0a1d01e446..da36d17f08 100644 --- a/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -39,5 +39,31 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Bearer token processing capabilities. + /// This middleware understands appropriately + /// formatted and secured tokens which appear in the request header. If the Options.AuthenticationMode is Active, the + /// claims within the bearer token are added to the current request's IPrincipal User. If the Options.AuthenticationMode + /// is Passive, then the current request is not modified, but IAuthenticationManager AuthenticateAsync may be used at + /// any time to obtain the claims from the request's bearer token. + /// See also http://tools.ietf.org/html/rfc6749 + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 34b2ae0709..4066fa4ed7 100644 --- a/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Microsoft Account authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs index 93db92caba..5599407ca3 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware>(options); } + + /// + /// Adds the middleware to the specified , which enables OAuth 2.0 authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware>(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index 5f22512261..329820417c 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables OpenID Connect authentication capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 024d04e697..1701122b0a 100644 --- a/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Builder /// The to add the middleware to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, Action configureOptions = null) + public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, Action configureOptions) { if (app == null) { @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables Twitter authentication capabilities. + /// + /// The to add the middleware to. + /// An action delegate to configure the provided . + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs index 702e65627b..21f80419f7 100644 --- a/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Authentication/ClaimsTransformationAppBuilderExtensions.cs @@ -58,5 +58,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables claims transformation capabilities. + /// + /// The to add the middleware to. + /// The to configure the middleware with. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseClaimsTransformation(this IApplicationBuilder app, ClaimsTransformationOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } diff --git a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs index c44a39360e..95d52e55f0 100644 --- a/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs +++ b/src/Microsoft.AspNet.CookiePolicy/CookiePolicyAppBuilderExtensions.cs @@ -33,5 +33,25 @@ namespace Microsoft.AspNet.Builder return app.UseMiddleware(options); } + + /// + /// Adds the middleware to the specified , which enables cookie policy capabilities. + /// + /// The to add the middleware to. + /// A that specifies options for the middleware. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseCookiePolicy(this IApplicationBuilder app, CookiePolicyOptions options) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + return app.UseMiddleware(options); + } } } \ No newline at end of file