Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Individual User Accounts auth option in ASP.NET Core Web API template

I am a bit confused as to why there is no Individual User Accounts authentication option in the latest ASP.NET Core Web API template.

Is it still possible to implement individual user accounts the way that the MVC template does or would it not make sense?

Let's say I am creating a stand-alone web API that is going to have all of my business logic and data layer that accesses the database which has the AspNet Identity tables. I plan on making calls to this API w/ an MVC app.

I know one way of doing this is to create an asp.net MVC app w/ individual user accounts auth and simply build the API right within the MVC app using a controllers/api folder. However, I don't want to do it this way because I want the API to be its own standalone project that can be hosted on a completely different server and accessed by multiple applications, not just an MVC app.

Can someone lead me in the right direction on how authentication typically works in this scenario since there is no template?

like image 248
Blake Rivell Avatar asked Dec 09 '16 13:12

Blake Rivell


People also ask

How do I change my authentication to individual accounts?

From the ASP.NET project window select "WebAPI". Click on the "Change Authentication" button. From the Change Authentication dialog select "Individual User Accounts". Click on the "OK" button.

How do I generate token based authentication in Web API .NET core?

To do so, add an empty Web API Controller, where we will add some action methods so that we can check the Token-Based Authentication is working fine or not. Go to Solution Explorer > Right click on the Controllers folder > Add > Controller > Select WEB API 2 Controller – Empty > Click on the Add button. >

How many types of authentication are there in asp net core?

Implementing security in a site has the following aspects: Authentication : It is the process of ensuring the user's identity and authenticity. ASP.NET allows four types of authentications: Windows Authentication.

How do I authenticate Web API?

Web API assumes that authentication happens in the host. For web-hosting, the host is IIS, which uses HTTP modules for authentication. You can configure your project to use any of the authentication modules built in to IIS or ASP.NET, or write your own HTTP module to perform custom authentication.


2 Answers

Individual User Accounts authentication option for the ASP.NET Core Web API is available in .NET Core 2.0 Preview 1.

Unfortunately .NET Core 2.0 Preview 1 isn't available in VS 2017 release.

But you can install Visual Studio 2017 Preview (you can use it side-by-side with VS 2017 stable version) :enter image description here

like image 57
Alexan Avatar answered Oct 06 '22 20:10

Alexan


I think you can use IdentityServer4 which allows implementing single sign-on and access control for ASP .NET Core Web APIs using protocols like OpenID Connect and OAuth2. It offers integration with ASP.NET Core Identity and Entity Framework Core.

You will need to install to the following nuget package:

Install-Package IdentityServer4 

and add the IdentityServer middleware to the HTTP pipeline:

app.UseIdentityServer(); 

You can find several quick start samples here or follow this article.

like image 23
Mihaela Diaconu Avatar answered Oct 06 '22 21:10

Mihaela Diaconu