Auth0 Authentication Example
This is a quick guide on setting up Backoffice authentication with Auth0.
Prerequisites
Auth0.AspNetCore.AuthenticationSetting up Ucommerce Backoffice
var ucommerceBuilder = builder.Services
.AddUcommerce(builder.Configuration)
.AddBackOffice(securitySettings =>
{
securitySettings.AddExternalIdentityProvider<MyExternalClaimsMapper>(
Auth0Constants.AuthenticationScheme,
authenticationBuilder =>
{
// Use the AuthenticationBuilder from ASP.NET to set up authentication
authenticationBuilder
.AddAuth0WebAppAuthentication(Auth0Constants.AuthenticationScheme,
auth0Options =>
{
auth0Options.Domain = builder.Configuration["Auth0:Domain"]!;
auth0Options.ClientId = builder.Configuration["Auth0:ClientId"]!;
// Ucommerce will handle the cookie session, so we disable it for Auth0
auth0Options.SkipCookieMiddleware = true;
});
});
// Configure Ucommerce to use your scheme from code
securitySettings.UseExternalIdentityProvider(Auth0Constants.AuthenticationScheme);
}
)
...Create your Auth0 application
Related Articles
Last updated