Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@ The `RedirectToLogin` component (`RedirectToLogin.razor`):
Inspect the `RedirectToLogin` component in [reference source](https://github.com/dotnet/aspnetcore/tree/main/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp). The location of the component changed over time, so use GitHub search tools to locate the component.

[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)]

The project template uses a well-known login path (`authentication/login`). When the app relies on a login endpoint from the OIDC discovery document (`/.well-known/openid-configuration`), <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationApplicationPathsOptions.LogInPath%2A?displayProperty=nameWithType> contains the login path. Change the login redirect in the `RedirectToLogin` component to use the configured path, as the following code demonstrates.

Add the following directives at the top of the `RedirectToLogin` component:

```razor
@using Microsoft.Extensions.Options
@inject IOptionsSnapshot<RemoteAuthenticationOptions<ApiAuthorizationProviderOptions>> Options
```

Modify the component's redirect in the `OnInitialized` method:

```diff
- Navigation.NavigateToLogin("authentication/login");
+ Navigation.NavigateToLogin(
+ Options.Get(Microsoft.Extensions.Options.Options.DefaultName)
+ .AuthenticationPaths.LogInPath);
```