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

View File

@ -6,6 +6,7 @@
"Microsoft.AspNet.Security": "", "Microsoft.AspNet.Security": "",
"Microsoft.AspNet.Security.Cookies": "", "Microsoft.AspNet.Security.Cookies": "",
"Microsoft.AspNet.Hosting": "0.1-alpha-*", "Microsoft.AspNet.Hosting": "0.1-alpha-*",
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*",
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*", "Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
"Microsoft.AspNet.Abstractions": "0.1-alpha-*", "Microsoft.AspNet.Abstractions": "0.1-alpha-*",
"Microsoft.AspNet.FeatureModel": "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) 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. // TODO: Use UseMiddleware to inject dependencies once it can discover Invoke from a base class.
var dataProtectionProvider = app.ServiceProvider.GetService<IDataProtectionProvider>(); var dataProtectionProvider = app.ApplicationServices.GetService<IDataProtectionProvider>();
var loggerFactory = app.ServiceProvider.GetService<ILoggerFactory>(); var loggerFactory = app.ApplicationServices.GetService<ILoggerFactory>();
return app.Use(next => new CookieAuthenticationMiddleware(next, dataProtectionProvider, loggerFactory, options).Invoke); return app.Use(next => new CookieAuthenticationMiddleware(next, dataProtectionProvider, loggerFactory, options).Invoke);
} }
} }