They deliberately abandoned this, because ASP.NET no longer works. This is a complete rewrite that is no longer dependent on System.Web, which is required for previous security templates. The framework uses what they learned from OWIN, and includes this. ASP.NET 5 is the new breed of OWIN. But middleware is added in exactly the same way. Previous middleware libraries for OWIN should work in ASP.NET 5.
@Pascal, that @DavidL means that in the web application pipeline you add authentication as middleware. You do this as an extension method on IAppBuilder.
First you need to add the authentication library as a dependency in the project.json file:
"dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
Then you should look at the examples on the official MicroSoft ASP.NET Security GitHub page
Look at the lines:
using Microsoft.AspNet.Authentication.Cookies;
and
app.UseCookieAuthentication(options => { options.AutomaticAuthentication = true; }); app.Run(async context => { if (string.IsNullOrEmpty(context.User.Identity.Name)) { var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") })); context.Authentication.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, user); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello First timer"); return; } context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello old timer"); });
This should appear before app.UseMvc () in the MVC 6 web application. Hope this helps :)
source share