Create cookie auth middleware with DI.
This commit is contained in:
parent
d02f76a2fd
commit
e2d3598438
|
|
@ -18,15 +18,12 @@ namespace Microsoft.AspNet.Builder
|
|||
/// <summary>
|
||||
/// Adds a cookie-based authentication middleware to your web application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="app">The IAppBuilder passed to your configuration method</param>
|
||||
/// <param name="app">The IBuilder passed to your configuration method</param>
|
||||
/// <param name="options">An options class that controls the middleware behavior</param>
|
||||
/// <returns>The original app parameter</returns>
|
||||
public static IBuilder UseCookieAuthentication([NotNull] this IBuilder app, [NotNull] CookieAuthenticationOptions options)
|
||||
{
|
||||
// TODO: Use UseMiddleware to inject dependencies once it can discover Invoke from a base class.
|
||||
var dataProtectionProvider = app.ApplicationServices.GetService<IDataProtectionProvider>();
|
||||
var loggerFactory = app.ApplicationServices.GetService<ILoggerFactory>();
|
||||
return app.Use(next => new CookieAuthenticationMiddleware(next, dataProtectionProvider, loggerFactory, options).Invoke);
|
||||
return app.UseMiddleware<CookieAuthenticationMiddleware>(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,8 @@
|
|||
"Microsoft.AspNet.Http": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.HttpFeature": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Security": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Security": "",
|
||||
"Microsoft.AspNet.Security.DataProtection": "0.1-alpha-*",
|
||||
"Microsoft.Framework.DependencyInjection": "0.1-alpha-*",
|
||||
"Microsoft.Framework.Logging": "0.1-alpha-*",
|
||||
|
|
|
|||
Loading…
Reference in New Issue