-
Notifications
You must be signed in to change notification settings - Fork 6k
WebSecurityConfiguration should autowire PermissionEvaluator #5272
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
Comments
Thanks for the report. A fix is now pushed to master and 5.0.x |
Thank you for addressing the issue so quickly! |
No problem. Thanks for the report! If you get a chance it would be nice to hear if the changes work for you. The SNAPSHOTs should be published within 30 minutes if you want to give it a try. |
The default instance of DefaultWebSecurityExpressionHandler uses the PermissionEvaluator Bean by default. Fixes: gh-5272
The default instance of DefaultWebSecurityExpressionHandler uses the PermissionEvaluator Bean by default. Fixes: gh-5272
I tested just now with spring security 5.0.5.BUILD-SNAPSHOT by means of adding
to my pom.xml. The version I got was: using https://repo.spring.io/snapshot/org/springframework/security/spring-security-bom/5.0.5.BUILD-SNAPSHOT/spring-security-bom-5.0.5.BUILD-20180430.173119-29.pom Unfortunately, the bug was still reproducible - I'm getting a DenyAllPermissionEvaluator instead of the expected one. I believe the reason why this is happening is because your code isn't in there... I checked the source jar and |
Thanks for the fast follow up. You are right that the build was failing. It should have published recently. Can you try again and force updates? |
I tested again just now, updating snapshots and the problem isn't resolved. It would appear that a new snapshot has yet to be published. |
@candrews Once again thank you for your fast response. I have a sample project that demonstrates this is working at https://github.com/rwinch/spring-security-sample/tree/gh-5272-permissionevaluator NOte that it is on branch gh-5272-permissionevaluator Run the tests to see it fail:
then run it again with the fix profile to use the latest 5.0.5.BUILD-SNAPSHOT
Is your sample working yet? If not, can you please provide a sample that is broken? Feel free to base it off the sample I provided. |
I'm closing this due to no more feedback. In the tests and the external sample project I provided it works. |
I confirm - it works fine. My apologies for my delayed reply. |
@candrews Thanks for the follow up and thanks again for raising this issue! |
This issue effectively reopens #4077.
GlobalMethodSecurityConfiguration
autowiresPermissionEvaluator
from the context:https://github.com/spring-projects/spring-security/blob/4.1.3.RELEASE/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java#L154
WebSecurityConfiguration
should do the same thing.Currently, it's surprising that when a
PermissionEvaluator
is set up, it just works (with no configuration other than declaring thePermissionEvaluator
bean) when used from Java annotations but the same expression always returns denied (as that's what the default configuration does) when used from in a web context (such as in a JSP sec: expression).Using thymeleaf spring security extras, you can conditionally show elements like this:
<div sec:authorize="hasPermission(#vars.study,'DELETE')">
The DefaultWebSecurityExpressionHandler that ends up being used has a type of
org.springframework.security.access.expression.DenyAllPermissionEvaluator
instead of the permission evaluator.This behavior worked as expected with the commit accepted from my pull request, 3bf6bf1, but some polish was done that made it no longer work, 8a66d0c.
Thanks again in advance for looking into this issue.
The text was updated successfully, but these errors were encountered: