dotnet / dotnet/aspnetcore

Blazor Standalone Webassembly - Unable to configure multiple IdP with Azure AD

Open
#41,682 11 comments 1 reaction 0 assignees View on GitHub
area-blazor enhancement feature-blazor-msal feature-blazor-wasm feature-blazor-wasm-auth Pillar: Complete Blazor Web
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I have a **Standalone Client side Blazor Web Assembly** hosed in the Azure Static Web App.

Currently its configured to authenticate with Azure AD using MSAL.

// Add Msal
builder.Services.AddMsalAuthentication(options =>
{
builder.Configuration.Bind("LoginAd", options.ProviderOptions.Authentication);

// For linux apps specify issues expliclity
// - https://github.com/dotnet/AspNetCore.Docs/issues/21228
// - https://github.com/dotnet/aspnetcore/issues/25430
// !--https://github.com/dotnet/aspnetcore/issues/38082 --> < PublishTrimmed > false
//
options.ProviderOptions.Authentication.Authority = "https://login.microsoftonline.com/common";

options.ProviderOptions.LoginMode = "redirect";

options.ProviderOptions.DefaultAccessTokenScopes.Add("openid");
options.ProviderOptions.DefaultAccessTokenScopes.Add("offline_access");
options.ProviderOptions.DefaultAccessTokenScopes.Add("profile");
options.ProviderOptions.DefaultAccessTokenScopes.Add("email");

}).AddAccountClaimsPrincipalFactory();

This enables me to authenticate any Microsoft work, school and personal account using standard auth routes.

`authentication/login`
`authentication/logout`

I need to add additional identity providers.

```
uilder.Services.AddAuthentication().AddOpenIdConnect( { idp1

uilder.Services.AddAuthentication().AddOpenIdConnect( { idp2

uilder.Services.AddAuthentication().AddOpenIdConnect( { idp3
```

I can add these services in the Program.cs but, how to tell the Blazor engine to initiate authentication with a specific IDP ?

Example:
`authentication/login/idp1`

### Describe the solution you'd like

The DI services enables adding multiple OpenId Connect IdPs, I want to pass certain hint so that the Blazor WASM engine `authentication\login` can initiate the authentication for a specific IdP.

### Additional context

Visual Studio 2022
.NET 603
Standalone Blazor Web Assembly
Azure Static Web App

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.