Hello Bernhard S,
Thank you for posting your question in the Microsoft Q&A forum.
The core challenge lies in Azure AD B2C’s limitations—it’s designed for user authentication, not for directly securing backend resources like Key Vault. Instead of using the B2C token to access Key Vault, adopt a middleware API approach:
Authentication Flow:
- Users authenticate via B2C in your Blazor app.
- The app sends the B2C token to your custom API (validated via [Authorize]).
API-to-Key Vault Access:
- Configure the API’s app registration (in Azure AD, not B2C) with Key Vault permissions (Key Vault Secrets User).
- Use the API’s managed identity or a client secret/certificate to fetch secrets, not the user’s B2C token.
Why This Works:
- B2C tokens lack Key Vault’s aud claim (they’re for user auth, not resource access).
- The API acts as a trusted intermediary, isolating B2C from backend services.
For testing, mock the API’s Key Vault access locally using DefaultAzureCredential. This architecture maintains security while bypassing B2C’s inherent restrictions.
If the above answer helped, please do not forget to "Accept Answer" as this may help other community members to refer the info if facing a similar issue. Your contribution to the Microsoft Q&A community is highly appreciated.