I’ve set up sign-in for multi-tenant Azure Active Directory using custom policies in Azure Active Directory B2C, so administrators of the Azure ADs can manage their own users. The sign-in works and I now want to support app roles.
I’ve defined app roles in the application manifest of the Azure AD B2C application and the roles are selectable in the Azure ADs. So far, so good, but the roles
claim isn’t included in the obtained token when signing in. I found that the roles
claim isn’t included by default in tokens issued by Azure AD B2C, but is it somehow possible to include the roles?
The roles are defined in the application manifest:
The roles are selectable in the Azure ADs:
2
Answers
Solved by passing through the
roles
claim:roles
to the ClaimsSchema element:Save the TrustFrameworkExtensions.xml file.
Open the relying party policy file, such as SignUpOrSignIn.xml, and add the OutputClaim element to the TechnicalProfile:
The token now includes roles:
Please check if below references can be worked around:
Please try to include assign the user to the same app roles from
azure ad tenant by assigning users/groups to the created app roles as you did.Then refresh the portal and app and
Then try to get token from b2c endpoint.
Please try to check the use of custom claims in azure ad B2C in which the consumer can select required role during the signup process which is returned in the token as well.
reference:
https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-rest-api-step-custom
for more details.
Try to create an extension attribute with some name extension_role .
read the attribute on sign in/up:
reference: custom-roles-on-azure-ad-b2c|SO
reference
Other reference: