It sounds like you're facing a common challenge with managing app roles across multiple app registrations. Here are some suggestions to help you read user role claims in your Web App without duplicating roles in both app registrations:
Solution: Use API Permissions and Token Configuration
Configure API Permissions:
- In the Azure portal, navigate to the app registration for your Web App.
- Under "API permissions," add the necessary permissions for the Web API. Ensure that the roles ToDoList.Read and ToDoList.ReadWrite are included.
- Update Token Configuration: In the app registration for your Web API, ensure that the roles are included in the token configuration. Navigate to "Token configuration" and add the roles claim.
- Modify Web App Code: Ensure that your Web App is configured to read the role claims from the token. Here is an example of how to read the role claims in your ASP.NET Core application:
var userRoles = User.Claims .Where(c => c.Type == "roles") .Select(c => c.Value) .ToList();