[BUG] Creating a role in the azure app registration doesn't do anything for spring #17171
Closed
3 tasks done
Labels
azure-spring
All azure-spring related issues
azure-spring-aad
Spring active directory related issues.
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Describe the bug
I created a role in the app registration as described here, it says to create the role and then you can do
@Preauthorize("hasRole('CUSTOM_ROLE')")
on an endpoint, but it doesn't find the custom role.Exception or Stack Trace
When navgating to the protected endpoint I get this:
To Reproduce
Steps to reproduce the behavior:
@PreAuthorize("hasRole('CUSTOM_ROLE')")
protecting itCode Snippet
Expected behavior
With those steps completed above, you should be able to access that endpoint.
Screenshots
If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
Additional context
I have a bit of experience playing with this stuff. I notice that I do get granted that role, but but not the authority.
the
@Preauthorize
annotation looks for granted authorities containing the provided role. So as it stands I only ever haveGranted Authorities: [[ROLE_USER]]
assigned to me. And if I keep looking at the securityContext, I see that I haveroles=["ROLE_ADMIN"]
(ROLE_ADMIN being the custom role I created). The README for the library (the bullet points below the code block) says that you should be granted authorization to access with this, but that is not the case.Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: