Implementing Role based SSO

moiz ajmal 0 Reputation points
2025-10-03T17:31:23.0333333+00:00

Hello
I am trying to implement role based SSO in one of my blazor server application. The expected behavior is if user is not authorized then they should not be allowed to view a page but the application should be accessible. However the issue I am facing is after logging the app is asking for a justification to access the app and then displaying a message as Request pending. Please refer attached screenshot for more reference.

User's image

I don't want this behavior, after entering the credentials the user should be allowed to use the app and only pages should be accessible based on permissions.

Any suggestions here would be welcome.

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alex Burlachenko 18,310 Reputation points Volunteer Moderator
    2025-10-07T06:57:34.18+00:00

    Hi moiz,

    you're hitting azure ad's application assignment requirements. The system is basically asking "is this user actually allowed to use this app?" before even letting them in.

    What's happening is your app registration in azure portal has this setting enabled where users must be explicitly assigned. So even with valid credentials, azure ad blocks them until an admin manually approves access. go to your azure portal and find your app registration. Navigate to the 'Enterprise application' blade for your app. Look for 'Properties' and then find the 'Assignment required?' setting. You want to set this to 'No'. This tells azure ad that any user in your tenant can access the app without manual approval.

    But wait... this might feel too open, right? You still want role based control, just not that manual approval step.

    The better approach is to keep assignment required set to 'Yes', but then pre assign your users or groups. Go to 'Users and groups' in your enterprise application and add all the users or security groups that should have access. This way, azure ad knows upfront who's allowed in, and your users won't see that pending request screen.

    Now, for the role based part within your blazor app... In your blazor components, you need to implement proper authorization checks. Since you're using azure ad, the roles should be coming through as claims. Make sure your app is configured to map the roles claim properly.

    In your program.cs or startup, ensure you have this configured

    builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration) .EnableTokenAcquisitionToCallDownstreamApi() .AddInMemoryTokenCaches();

    builder.Services.AddAuthorization(options => { options.FallbackPolicy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); });

    Then in your blazor components, use the Authorize attribute to control access:

    @attribute [Authorize(Roles = "Admin,Manager")]

    For more granular control within pages, you can use the AuthorizeView component:

    <AuthorizeView Roles="Admin"> <Authorized> <p>You can only see this if you're an admin!</p> </Authorized> <NotAuthorized> <p>Sorry, you need admin rights for this section.</p> </NotAuthorized> </AuthorizeView>

    check your app's authentication settings in the azure app configuration. Make sure the redirect uris are correct and the token configuration includes role claims. Sometimes the roles don't come through because the token isn't configured to include them.

    You might need to update your app registration manifest to include "groupMembershipClaims": "SecurityGroup" or "ApplicationRole" depending on how you're managing roles.

    This microsoft doc explains the user assignment requirements really well https://free.blessedness.top/en-us/azure/active-directory/manage-apps/assign-user-or-group-access-portal.

    The key is separating the azure ad level access (who can enter the app) from your application level role checks (what they can do inside). Fix that assignment requirement first, then make sure your role claims are flowing through properly

    regards,

    Alex

    and "yes" if you would follow me at Q&A - personaly thx.
    P.S. If my answer help to you, please Accept my answer
    

    https://ctrlaltdel.blog/


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.