Difference between WebExpressionVoter and AuthenticatedVoter in spring security

耗尽温柔 提交于 2021-02-07 08:54:55

问题


What is the difference between WebExpressionVoter and AuthenticatedVoter in spring security? What I know is AuthenticatedVoter will search for strings IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_ANONYMOUSLY, IS_AUTHENTICATED_REMEMBERED (cookie) and vote for yes in corresponding cases. But I am not sure of WebExpressionVoter even afetr reading available spring docs. Please any one explain me about WebExpressionVoter. Thanks in advance.


回答1:


Take a look at Web Security Expressions.

The WebExpressionsVoter is enabled by the use-expressions="true" setting on http element config. For example:

<http use-expressions="true"> <intercept-url pattern="/admin*" access="hasRole('admin')"/> ... </http>

The above example allows you to use SpEL expressions in the intercept-url element attribute access. The expression hasRole('admin') expression is evaluated against an expression root object, for example, a base class of SecurityExpressionRoot -> WebSecurityExpressionRoot



来源:https://stackoverflow.com/questions/36975740/difference-between-webexpressionvoter-and-authenticatedvoter-in-spring-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!