A challenge scheme decides what happens when an unauthenticated user requests a protected resource. It differs from the authentication scheme, which reads the current identity to determine whether the user is authenticated. In the UI app, cookies handle authentication and OpenID Connect (OIDC) handles the challenge by redirecting the user to an identity provider. section 8.3
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme =
CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme =
OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(
CookieAuthenticationDefaults.AuthenticationScheme)
.AddOpenIdConnect()
.ConfigureWebAppOpenIdConnect();
The startup configuration sets DefaultScheme to cookies and DefaultChallengeScheme to OIDC, then registers both schemes. section 8.3
Protected UI resource
When an unauthenticated user requests a UI resource marked [Authorize], the configured OIDC challenge redirects them to sign in. section 8.3
