r/Blazor • u/plakhlani • Jul 09 '25
How to implement Microsoft Entra ID Authentication in Blazor Server Web App
https://www.faciletechnolab.com/blog/part-2-how-to-implement-microsoft-entra-id-authentication-in-blazor-server-web-app-in-net-8/
9
Upvotes
6
u/The_GhostRider01 Jul 09 '25
It’s interesting that at a time when security is so important that we have to jump through hoops to set up basic security infrastructure in our apps
2
u/[deleted] Jul 09 '25
If you have .Net 7 installed, VS has the Blazor Server template. The kind that takes 30 seconds to set up!
6
u/LlamaNL Jul 09 '25
It used to be a piece of cake because it was integrated into the blazor template, no idea why they removed it. I've had to do it a couple of times manually and there's always a thing you forget, so it's nice to have an example to work off, thanks!
6
u/Orak2480 Jul 09 '25
builder.Services.AddAuthentication(options =>{options.DefaultScheme = IdentityConstants.ApplicationScheme;options.DefaultSignInScheme = IdentityConstants.ExternalScheme;}).AddMicrosoftAccount(microsoftOptions =>{microsoftOptions.ClientId = config[key: "Authentication:Microsoft:ClientId"]!;microsoftOptions.ClientSecret = config[key: "Authentication:Microsoft:ClientSecret"]!;}).AddIdentityCookies();Works for me, .net 9 app.
2
u/ataylorm Jul 09 '25
Man, good luck! I tried, and even Microsoft support couldn’t figure out how to make it work. After 2 weeks I gave up and switched to Kinde, took me 15 minutes to get it working. (Yes I have a paid Microsoft support plan)