简体   繁体   中英

Is there a way to add role-based authentication in ASP.NET Core Web API?

I am trying to create an ASP.NET Core Web API project with role-based authorization, but there isn't any guide or article about it without using ASP.NET Core web app and razor pages which I don't want to use because I am making my own UI in angular. But also I want to do all logic behind authentication and authorization on BE.Is there any guide for step-by-step implementation of role-based authorization?

I have 3 roles: sysAdmin, employee, patient .

I have only one option for authentication and authorization and that is checking if session is expired for that account, but how do I hide content for that user?

When we have a web app, we can let users sign in and the request are all inside the server, so the cookie which contained user information can worked well for authorization. but when you have a SPA + web api, they usually use access token for authorization. and that's why I share the link with you, it showed how to authenticate the SPA.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM