ASP.NET Core Identity in a Web API

Scottish Smile

Are there any guides on how to set up ASP.NET Core Identity for a Web API?

Everything I find uses view models and has the register/login pages displayed on the server as a RazorPage.

MS's Intro document also does this - https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-6.0&tabs=visual-studio

This seems a very old style of set up.

I want my React client to display the register/login forms.

The Web API should just have a registration and login endpoint that returns a DTO. ASP.NET Core Identity being used to store the users in a database in the API, and manage authentication and authorization.

Am I barking up the wrong tree perhaps? Maybe ASP.NET Core Identity just doesn't work this way and I should instead use a hosted user management/authentication solution like AWS Cognito or Auth0?

Thanks

Pouya Hashemi

Take a look at this article. It provides the basics of installing packages and configuring them. However to register new users or login users you need to use UserManager and SignInManager classes.

This is the full code of how to implement it with JWT;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ASP.NET Core Web API Authentication

ASP.NET Web API get user identity in controller constructor

ASP.Net Core routes with Web API

Post files from ASP.NET Core web api to another ASP.NET Core web api

ASP.Net web api Vs .Net core web api

ASP.NET Core Web API vs ASP.NET Core Application

Access user identity from controller in ASP.NET Core Web API

ASP.NET Core Sharing Identity Cookie across azure web apps on default domain (*.azurewebsites.net)

ASP .NET Core Identity SignInManager

IdentityServer4 Role Based Authorization for Web API with ASP.NET Core Identity

ASP.NET Web API 2.0 pipeline and ASP.NET Core Web API pipeline differences

Multiple MemoryCache in ASp .Net Core Web API

How to refresh CSRF token on login when using cookie authentication without identity in ASP .NET Core Web API

ASP.NET Core Web API client does not trust self-signed certificate used by the Identity Server instance

Use .NET Core Identity with an API

Simple Injector Registration ASP.NET identity & Web API

Restrict access to register users in ASP.NET Web API and Identity

Get User Roles with ASP.net Identity and Web API

ASP .Net Core web app calling a Web API

How to make ASP.Net Core Web API Identity return a 401 on unauthorized

Asp.Net Identity connecting to DB via Web Api

ASP.Net Core API: How to link User Identity to a Contact

debugging the asp.net core web API

Which project should I add .Net Core Identity (Web API or in Web Client)?

How is access restricted in the ASP.NET Core web app template when using ASP.NET Core Identity

ASP.NET Core Web API using Entity Framework Core

Restrict Access with Azure Managed Identity in .NET Core Web API

ASP.NET Core MVC & ASP.NET Core Web API in same project

How to check if user is logged in to ASP.NET Core web application when using ASP.NET Core Web API to house identity