Update based on new API changes

This commit is contained in:
David Fowler 2014-04-17 22:25:17 -07:00
parent 689bdf2072
commit 9726a26056
3 changed files with 11 additions and 8 deletions

View File

@ -6,6 +6,7 @@ using Microsoft.AspNet.DependencyInjection;
using Microsoft.AspNet.DependencyInjection.Fallback;
using Microsoft.AspNet.Logging;
using Microsoft.AspNet.Security.Cookies;
using Microsoft.AspNet.RequestContainer;
namespace CookieSample
{
@ -13,15 +14,16 @@ namespace CookieSample
{
public void Configuration(IBuilder app)
{
// TODO: Move to host.
var serviceCollection = new ServiceCollection();
serviceCollection.AddInstance<ILoggerFactory>(new NullLoggerFactory());
app.ServiceProvider = serviceCollection.BuildServiceProvider(app.ServiceProvider);
app.UseServices(services =>
{
// TODO: Move to host.
services.AddInstance<ILoggerFactory>(new NullLoggerFactory());
});
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
{
});
});
app.Run(async context =>
{

View File

@ -6,6 +6,7 @@
"Microsoft.AspNet.Security": "",
"Microsoft.AspNet.Security.Cookies": "",
"Microsoft.AspNet.Hosting": "0.1-alpha-*",
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*",
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
"Microsoft.AspNet.Abstractions": "0.1-alpha-*",
"Microsoft.AspNet.FeatureModel": "0.1-alpha-*",

View File

@ -22,8 +22,8 @@ namespace Microsoft.AspNet
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.ServiceProvider.GetService<IDataProtectionProvider>();
var loggerFactory = app.ServiceProvider.GetService<ILoggerFactory>();
var dataProtectionProvider = app.ApplicationServices.GetService<IDataProtectionProvider>();
var loggerFactory = app.ApplicationServices.GetService<ILoggerFactory>();
return app.Use(next => new CookieAuthenticationMiddleware(next, dataProtectionProvider, loggerFactory, options).Invoke);
}
}