-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UrlAuthorizationConfigurer should not call hasRole(ROLE_ANONYMOUS) #6353
Conversation
@msdousti Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@msdousti Thank you for signing the Contributor License Agreement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @msdousti! Can you please add a test?
@rwinch : Thanks for attending the issue. Here's a simple class that, if added to your code base, causes error:
Upon compiling the project, I get the following error:
The important line is:
|
Thank you. Can you please turn that into a test and update the PR by pushing to your existing branch? Since it is a private branch, please squash your existing changes and the test in a single commit. |
java.lang.IllegalArgumentException: ROLE_ANONYMOUS should not start with ROLE_ since ROLE_ is automatically prepended when using hasRole. Consider using hasAuthority or access instead. Also, added the corresponding test.
@rwinch: I added a test, which passes only if it is compiled against After some tweaking, I also squashed my existing changes and the test in a single commit. |
...g/springframework/security/test/web/configurers/UrlAuthorizationConfigurerAnonymousTest.java
Outdated
Show resolved
Hide resolved
...g/springframework/security/test/web/configurers/UrlAuthorizationConfigurerAnonymousTest.java
Outdated
Show resolved
Hide resolved
UrlAuthorizationConfigurerTests.java
Removed "ROLE_" from UrlAuthorizationConfigurer This fixes IllegalArgumentException: ROLE_ANONYMOUS should not start with ROLE_ since ROLE_
Thanks for the fast turnaround! This is now merged into master and backported via the listed issues above |
Let's take that up as a new issue. However, some of those are fine as you can change the prefix and some of the code is smarter. |
The following line:
spring-security/config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java
Line 347 in 5f33bbe
throws this exception:
The easiest remedy is to remove the
ROLE_
prefix. One can also usehasAuthority
oraccess
instead ofhasRole
, as suggested in the exception.