You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before the fix, the KeycloakAuthenticationToken was injected in the controller method via the ServletRequestMethodArgumentResolver. After the fix, the injection is supposed to be done by the AuthenticationPrincipalArgumentResolver, but that resolver always taken the principal of the authentication object. It does not check if the authentication object itself is also a principal as in the case of Keycloak.
The workaround is to remove the @AuthenticationPrincipal annotation (which I find a pity, the annotation made it clear that this argument was getting injected by the framework).
Maybe a note can be added to the release notes for this as others(1,2) have also had the issue?
The text was updated successfully, but these errors were encountered:
snicoll
transferred this issue from spring-projects/spring-boot
Apr 12, 2021
Indeed this should be in the release notes but is missing. I will also see about finding a place in the documentation to mention this as it can be confusing indeed.
I just spend a few hours trying to figure out why my upgrade from Spring Boot 2.3.4 to 2.4.4 was not working.
I am using Keycloak for authentication and my rest controller use this construct:
This works in Spring Boot 2.3.4, but not in Spring Boot 2.4.4. The reason for this is that in Spring 5.3.1 a bug on ServletRequestMethodArgumentResolver was fixed.
Before the fix, the KeycloakAuthenticationToken was injected in the controller method via the
ServletRequestMethodArgumentResolver
. After the fix, the injection is supposed to be done by theAuthenticationPrincipalArgumentResolver
, but that resolver always taken the principal of the authentication object. It does not check if the authentication object itself is also a principal as in the case of Keycloak.The workaround is to remove the
@AuthenticationPrincipal
annotation (which I find a pity, the annotation made it clear that this argument was getting injected by the framework).Maybe a note can be added to the release notes for this as others(1,2) have also had the issue?
The text was updated successfully, but these errors were encountered: