Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no authentication for the asp.net 5.0 preview - web api template -

I have created a web project in the new Visual Studio 2015.

I can choose asp.net 4.6 or 5.0 preview web api template. The old 4.6 has

authentication but I want to use the new 5.0 preview also web api.

But this template lacks the authentication, but why?

like image 569
Pascal Avatar asked Sep 28 '22 23:09

Pascal


1 Answers

In the OWIN world you provide the Authentication you need when you need it. his is the new paradigm of the ASP.NET 5 world. "You are only provided what you explicitly say you need. If you don't ask for it, you don't get it". This is just another example of that mindset.

Scott Guthrie calls this out in his recent post:

ASP.NET 5 introduces a new HTTP request pipeline that is modular so you can add only the components that you need. The pipeline is also no longer dependent on System.Web. By reducing the overhead in the pipeline, your app can experience better throughput and a more tuned HTTP stack. The new pipeline is based on many of the learnings from the Katana project and also supports OWIN.

To customize which components are used in the pipeline, use the Configure method in your Startup class. The Configure method is used to specify which middleware you want to “use” in your request pipeline. ASP.NET 5 already includes ported versions of many of the middleware from the Katana project, like middleware for static files, authentication and diagnostics. The following image shows some of the features you can add or remove to the pipeline for your project.

You can plug in your security very quickly; you just need to specify what it is that you'll be using.

public void Configure(IApplicationBuilder app)
{
    // Add static files to the request pipeline.
    app.UseStaticFiles();
 
    // Add cookie-based authentication to the request pipeline.
    app.UseIdentity();
 
    // Add MVC and routing to the request pipeline.
    app.UseMvc(routes =>
    {
    routes.MapRoute(
        name: "default",
        template: "{controller}/{action}/{id?}",
        defaults: new { controller = "Home", action = "Index" });
 
});
like image 198
David L Avatar answered Nov 15 '22 06:11

David L