question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I want to send a domain_hint from Blazor Web Assembly (using Microsoft.Extensions.DependencyInjection.MsalWebAssemblyServiceCollectionExtensions.AddMsalAuthentication ) #29440

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

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

Issue reference: https://stackoverflow.com/questions/63605653/is-there-a-way-to-supply-a-domain-hint-for-single-sign-on-using-msal-net-on-a-bl

domain_hint is a AuthenticationParameter of MSAL, which does not appear to be supported/exposed by the Microsoft.Authentication.WebAssembly.Msal package

Here are related issues for other Authentication parameters: extraQueryParameter: https://github.com/dotnet/aspnetcore/issues/25391 (https://github.com/dotnet/aspnetcore/issues/25391) loginHint: https://github.com/dotnet/aspnetcore/issues/19877 (https://github.com/dotnet/aspnetcore/issues/19925)

I believe this issue was unfairly closed with the suggestion that we could customize our own msal.js library. This is not the case; msal.js supports domain hints, it is the .NET MSAL library that doesn’t pass it through.

Describe the solution you’d like

I would hope that simply adding support for additional parameters, which will be passed through to MSAL.JS, would be easy to implement, test, and support. So in my client Program.cs, I could do:

WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);
...
builder.Services.AddMsalAuthentication(options =>{
    ...
    options.ProviderOptions.AddAdditionalProviderParameter("domain_hint","mydomain.com");
});

Alternatively, it would be acceptable to add explicit parameters for DomainHint and LoginHint.

    ...
    options.ProviderOptions.DomainHint = "mydomain.com";

Or is there some other way to do this that I am missing?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
javiercncommented, Dec 12, 2022

@szalapski I took another look, I think you should use “domainHint” and not “domain_hint” as per https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_browser.html#redirectrequest

If you still have issues after that, please let us know. I’ve created an issue to bring more clarity in the docs about this scenario.

1reaction
javiercncommented, Dec 12, 2022

@szalapski I am not sure about the specific way to achieve this in MSAL, my guess is that you are likely not passing the correct parameter downstream. If you want to know for sure, you can put a breakpoint on the JS right before the call to sign-in in MSAL and inspect that the values are what you expect.

What you see in the trace is literally what gets passed to msal-browser here

Read more comments on GitHub >

github_iconTop Results From Across the Web

MsalWebAssemblyServiceCollec...
Contains extension methods to add authentication to Blazor WebAssembly applications using Azure Active Directory or Azure Active Directory B2C.
Read more >
Secure an ASP.NET Core Blazor WebAssembly ...
This article explains how to create a standalone Blazor WebAssembly app that uses Azure Active Directory (AAD) for authentication.
Read more >
MsalWebAssemblyServiceCollec...
Adds authentication using msal.js to Blazor applications. AddMsalAuthentication(IServiceCollection, Action<RemoteAuthenticationOptions<MsalProviderOptions>>).
Read more >
ASP.NET Core Blazor dependency injection
A Blazor WebAssembly app. Blazor script start configuration is found in the wwwroot/index.html file. The Program file is Program.cs ...
Read more >
Sign in users and call a protected API from a Blazor ...
In this tutorial, sign in users and call a protected API using the Microsoft identity platform in a Blazor WebAssembly (WASM) app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found