Add sign-in with Microsoft Entra ID (or Microsoft account)
There is an AddMicrosoftEntraID method that sets up a number of settings that, in our experience, make sign-in work well with IRM.AspNetCore.Identity – for example error handling that tells the user why something went wrong. All of these settings can be overridden in your own options configuration, and there are also some required settings that must be provided, such as ClientId and ClientSecret.
services.AddAuthentication()
.AddMicrosoftAzureAd(options =>
{
options.ClientId = "ClientId from portal";
options.ClientSecret = "Secret from portal";
//The Prompt property can be used to force a login, or the consent screen. Per specification, “none”, “login”, “consent”,
//“select_account” values can be used here. If the login is not forced, the user will automatically be logged in, if only one
//account is active.
//options.Prompt = "select_account";
});Synchronize users’ groups from Entra ID with external groups
There is built-in support for synchronizing the security groups a user belongs to in Entra ID with the groups configured as external in group administration. To include the groups, the following configuration must be made in the App Registration in the Azure Portal:
- Open the configuration for your app, identified by the client id you used above.
- Click Token configuration.
- Click Add groups claim.
- Select Security groups.
- Under ID token, select Group ID and check Emit groups as role claims.
The user’s Entra ID security groups will now be included as their object ids in Entra ID. This means that when you configure an external group, you should enter the object id as the external group name.