简体   繁体   中英

Azure Active Directory B2C Custom Roles and Policies

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

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://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-rest-api-claims-exchange

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