我正在使用弹簧安全性,我必须同时使用过滤器链和命名空间。命名空间工作正常,但过滤器链似乎没有!
这是我的配置。一、命名空间:
<sec:global-method-security secured-annotations="enabled" />
<sec:http pattern="/app/login.jsp*" security="none" />
<sec:http pattern="/admin/login.jsp*" security="none" />
<sec:http pattern="/app/*.png" security="none" />
<sec:http pattern="/admin/*.png" security="none" />
<sec:http pattern="/app/**" authentication-manager-ref="authenticationManager"
access-decision-manager-ref="accessDecisionManager">
<sec:intercept-url pattern="/app/**" access="ROLE_USER" />
<sec:access-denied-handler error-page="/app/login.jsp?aer=" />
<sec:form-login login-processing-url="/app/j_spring_security_check"
always-use-default-target="true" default-target-url="/app/index.html"
login-page='/app/login.jsp' authentication-failure-url='/app/login.jsp?login_error' />
<sec:logout logout-url="/app/j_spring_security_logout"
invalidate-session="true" logout-success-url="/app/login.jsp" />
</sec:http>
<sec:http pattern="/admin/**" authentication-manager-ref="authenticationManager"
access-decision-manager-ref="accessDecisionManager">
<sec:intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<sec:access-denied-handler error-page="/admin/login.jsp?aer=" />
<sec:form-login login-processing-url="/admin/j_spring_security_check"
always-use-default-target="true" default-target-url="/admin/index.html"
login-page='/admin/login.jsp' authentication-failure-url='/admin/login.jsp?login_error' />
<sec:logout logout-url="/admin/j_spring_security_logout"
invalidate-session="true" logout-success-url="/admin/login.jsp" />
</sec:http>
这工作正常。但我还需要一个过滤器链来检查其他请求。(这些请求是动态创建的,我们必须以这种方式控制它们)
这是我的过滤器链:
<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
<security:filter-chain-map path-type="ant">
<sec:filter-chain pattern="/css/**" filters="none" />
<sec:filter-chain pattern="/common/**" filters="none" />
<sec:filter-chain pattern="/images/**" filters="none" />
<sec:filter-chain pattern="/login.jsp*" filters="none" />
<sec:filter-chain pattern="/rest/**"
filters="
ConcurrentSessionFilter,
securityContextPersistenceFilter,
logoutFilter,
authenticationProcessingFilter,
sessionManagementFilter,
exceptionTranslationFilter,
filterSecurityInterceptor" />
</security:filter-chain-map>
</bean>
问题是,过滤器链不控制任何东西。我确信当不使用命名空间时过滤器链工作正常。但是当我添加命名空间时,问题就开始了。
为什么?我不能用那个吗?或者我可以而且我必须改变一些东西?
更新:
调用此资源时,这是我的调试日志:/rest/asrv/gtallmmbrsofusrgrp
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/app/login.jsp*'
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/admin/login.jsp*'
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/app/*.png'
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/admin/*.png'
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/app/**'
DEBUG AntPathRequestMatcher - Checking match of request : '/rest/asrv/gtallmmbrsofusrgrp'; against '/admin/**'
DEBUG FilterChainProxy - /rest/asrv/gtallmmbrsofusrgrp has no matching filters