Identity Auth Customization in Asp.Net Core 8 Web API
Hi there! I'm using IdentityAPIEndpoints in my Web API. That includes many endpoints like register/login and others like for confirmation of email etc or 2fa and handles the whole authentication and authorization of the API.
But now I wanna implement the RBAC(Role Base Acsess) in it. What I have done so far is that I'm manually creating a admin user by default and assigning him the admin role . But after that now I want to assign every user that registers via the register endpoint provided by the identity, to assign a default User role. So far I've unabled to find the solution like how to assign the roles on registration as the registeration and the whole auth process is being handled by the identity and I've no access to the inside code.
Below is my Program.cs file :
1 Reply
How can I reach to the registration code behind the Identity's given endpoint to assign the default role to each user that registers ?
Solved
So what I did is that , I just created a custom register endpoint on top of the Identity endpoints by leveraging the user manager provided by the identity. So I'll register the users with this endpoint including my custom role assigning logic while the rest of the auth will be done by the other identity endpoints.
š