Microsoft Entra ID Example
This is a quick guide on setting up Backoffice authentication with Microsoft Entra ID.
Prerequisites
Microsoft.Identity.Web
Microsoft.Identity.Web.TokenCacheSetting up Ucommerce Backoffice
var ucommerceBuilder = builder.Services
.AddUcommerce(builder.Configuration)
.AddBackOffice(securitySettings =>
{
securitySettings.AddExternalIdentityProvider<MyExternalClaimsMapper>(
OpenIdConnectDefaults.AuthenticationScheme,
authenticationBuilder =>
{
IEnumerable<string>? initialScopes = builder.Configuration["DownstreamApi:Scopes"]
?.Split(' ');
// Use the AuthenticationBuilder from ASP.NET to set up authentication
authenticationBuilder.AddMicrosoftIdentityWebApp(builder.Configuration,
cookieScheme: null) // Ucommerce will handle the cookie session
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
.AddInMemoryTokenCaches();
});
// Configure Ucommerce to use your scheme from code
securitySettings.UseExternalIdentityProvider(OpenIdConnectDefaults.AuthenticationScheme);
}
)
...Create your Azure application
Related Articles
Last updated