Home > Net >  Azure Authentication only works for home page, not all pages in the blazor web assemble app
Azure Authentication only works for home page, not all pages in the blazor web assemble app

Time:12-29

I am trying to implement Azure AD authentication and authorization for a blazor web assembly hosted app. The authentication is only working if I request the home page. If I directly try to access other endpoints in the app, it loads the content even though I am not signed in. I would like to be prompted to enter credentials if I try accessing any page in the app. I am thinking I need some additional code or settings, but not understand how and where to do it. Please help.

CodePudding user response:

• I tried to create an Azure AD hosted Blazor web assembly app and integrate it with Azure AD authentication by using the github link below. It worked correctly for me as you can see in the snapshots below also: -

Github link : - AAD app registration

App build and execution in VS code: - App build in VS code

Blazor web assembly Application running output: - App output

Also, when I directly try to open a different page in the application after signing out, it requests me for signing into the application again as below: - Different page sign in

Please check the URL for the above displayed page as below: -

Required Authentication - Startup.cs

CodePudding user response:

@KartikBhiwapurkar-MT I am unable to comment directly to your answer because of the low reputation. Thank you for trying to help. I added the code in startup.cs. But it still loads the page without asking for credentials. I am running it locally thru IISExpress. The Redirect URIs in Azure Server app shows 2 spa (single page app); instead of 2 web as in your case. Does all this in anyway impact the behaviour?

enter image description here

  • Related