Reputation: 11
Good day, I am using .Net Core 3.1 Web app and Azure Active Directory B2C for user login, so far it works well and as expected. Now i want to use the Roles, Policies and Claims which are configured in per user in the sql server. Each user id (azure b2c object id) is mapped to Roles.
How do i retrieve them in the startup.cs file ? I need to use similar to :
services.AddAuthorization(options =>
{
options.AddPolicy("AdminAccess", policy => policy.RequireRole("Admin"));
});
Thank you very much advance. Regards
Upvotes: 0
Views: 3651
Reputation: 11315
You could use Azure AD Custom Policies, which allow you to call a REST API during authentication. This can be used to pass the ObjectId of the user to your API, and return the roles to Azure AD B2C. B2C can then issue the roles as a claim into the token.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-rest-api-claims-exchange
Upvotes: 2