In past MVC versions I was able to do
<roleManager enabled="true" defaultProvider="...." ...
in to the web.config to get a custom role provider, but that doesn't seem to be the case anymore.
Essentially what I want to do is:
- The user logs in.
- On success, get roles for user from external source.
- Apply roles to user to be used in code.
- Match user roles to roles in custom RoleProvider
How do I do this in ASP.NET Core?
If you're using simple cookie-based authentication instead of the Identity framework, you can add your roles as claims and they will be picked up by
User.IsInRole(...)
,[Authorize(Roles = "...")]
, etc.