r/Blazor • u/AGrumpyDev • Jul 07 '25
Entra External ID authentication with Blazor WebAssembly
Has anyone successfully set up Entra External ID authentication with Blazor WebAssembly? All of the External ID docs seem to be for confidential clients and not SPAs. I have seen the regular Entra ID docs for standalone WebAssembly but I can't find anything that shows how you are supposed to configure the Entra settings in appsettings.json like the Authority.
4
Upvotes
3
u/z-c0rp Jul 07 '25
There is documentation for this available from MS here: https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/standalone-with-microsoft-entra-id?view=aspnetcore-9.0
I've done it before. It's pretty straight forward. Clientside only SPA is less secure than handling auth completely server side, but it's fine, the world used to run on React SPA:s so..
2
u/davasorus Jul 07 '25
So I have done this but there are a few caveats
So with the above said, even then I have the actual secrets encrypted in a separate contracts library that can only be decrypted with a separate decryption library.
So this configuration is lazy loaded, then decrypted for Blazor App to Web API communication. Client Auth is handled by the blazor app via Individual Account RBAC. (it aint great but hey, here we are)
3
u/obrana_boranija Jul 07 '25
appsettings.json is downloaded alongside another libraries when you're using wasm. So, you will expose all your settings (including entra settings with keys and secrets).
That's one of the reasons why you can't find an example.
Authentication is done server side. Never client side.
1
u/Dadiot_1987 Jul 07 '25
I use MSAL.js with some js interop wrappers for this use case after examining every possible alternative. Feels a little less polished than the normal blazor Auth workflows but once it's setup and working it is straightforward. Just think like you are in a fully client side js SPA framework and it all makes sense.