SPA with .net Core3.1, ReactJs and IdentityServer with Role Based claim access
This project represents a sample that can be used for SPA projects using .net core 3.1 and ReactJs 16 with identityServer4 for authorization and authentication.
- The project is using a local sql lite as the database source.
- A token based authentication.
- A Role based authorisation.
- Registering identity service and adding RoleManager in
startup.cs
. - Creating and adding roles to identity with
CreateRoles
Task inStartup.cs
(Amin, Manager, Member). - Adding the role to the token via the class
ProfileService.cs
and then calling the taskCreateRoles
in configure method instartup.cs
. - Scaffolding identity with codegenerator tool to generate the identityServer UI for customization, retriving list of roles from the databse to be selected by users to bind each user to a role in
Register.cshtml.cs
. - Remove the registered services in
IdentityHostingStartup.cs
as it they are duplicated and the required services have been already registered instartup.cs
. - Adding rendering conditions in
NavMenu.js
to restrict tabs based on role claims.