我正在使用Spring Security来保护webapp.URL的安全性如下:
<security:http entry-point-ref="authenticationEntryPoint">
<security:intercept-url pattern="/" access="ROLE_ANONYMOUS" />
<security:intercept-url pattern="/assets/**/*" access="ROLE_ANONYMOUS" />
...
<security:intercept-url pattern="/**" access="ROLE_USER" />
<security:anonymous granted-authority="ROLE_ANONYMOUS" />
</security:http>
Run Code Online (Sandbox Code Playgroud)
我有一个过滤器,在某些情况下需要将用户重定向到特殊页面.但是,该页面需要资产目录中的图像和CSS文件,遗憾的是,这些文件也会被重定向到该特殊页面.我不希望过滤器手动检查每个URL模式,因为我的实际URL配置要长得多,而且我还想允许其他页面.
有没有办法从过滤器中确定给定页面需要哪些角色?如果不需要ROLE_ANONYMOUS,我可以选择不重定向.