Java 匿名身份验证spring403
你好(谢谢你的阅读;) 我遇到了一个非常恼人的情况: 首先,我想对我们的spring应用程序应用安全性, 我很高兴得到403,所以第二天我想真正授权人们申请 这似乎比预期的更难做到:( 经过一些预授权工作后,我们决定我们的应用程序不需要显式的spring安全性(因为我们有其他身份验证),所以我们选择匿名身份验证 我遵循了来自的指南进行预认证,并根据规范对其进行了调整,使其无可用性 (我仍然得到一个错误代码403) My applicationContext-security.xml:Java 匿名身份验证spring403,java,spring,authentication,spring-security,Java,Spring,Authentication,Spring Security,你好(谢谢你的阅读;) 我遇到了一个非常恼人的情况: 首先,我想对我们的spring应用程序应用安全性, 我很高兴得到403,所以第二天我想真正授权人们申请 这似乎比预期的更难做到:( 经过一些预授权工作后,我们决定我们的应用程序不需要显式的spring安全性(因为我们有其他身份验证),所以我们选择匿名身份验证 我遵循了来自的指南进行预认证,并根据规范对其进行了调整,使其无可用性 (我仍然得到一个错误代码403) My applicationContext-security.xml: &
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
<sec:filter-chain-map request-matcher="ant">
<sec:filter-chain pattern="/**" filters="anonymousAuthFilter"/>
</sec:filter-chain-map>
</bean>
<bean id="anonymousAuthFilter"
class="org.springframework.security.web.authentication.AnonymousAuthenticationFilter">
<constructor-arg value="foobar"/>
</bean>
<bean id="anonymousAuthenticationProvider"
class="org.springframework.security.authentication.AnonymousAuthenticationProvider">
<constructor-arg value="foobar"/>
</bean>
<bean id="filterSecurityInterceptor"
class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="httpRequestAccessDecisionManager"/>
<property name="securityMetadataSource">
<sec:filter-security-metadata-source>
<sec:intercept-url pattern='/index.jsp' access='ROLE_ANONYMOUS'/>
<sec:intercept-url pattern='/**' access='ROLE_ANONYMOUS'/>
</sec:filter-security-metadata-source>
</property>
</bean>
<bean id="httpRequestAccessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg>
<list>
<ref bean="roleVoter"/>
</list>
</constructor-arg>
<property name="allowIfAllAbstainDecisions" value="true"/>
</bean>
<bean id="roleVoter" class="org.springframework.security.web.access.expression.WebExpressionVoter"/>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider ref="anonymousAuthenticationProvider" />
</sec:authentication-manager>
</beans>
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
<filter>
<filter-name>filterChainProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>filterChainProxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<security-role>
<role-name>ROLE_USER</role-name>
</security-role>
<security-role>
<role-name>ROLE_SUPERVISOR</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>All areas</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>ROLE_USER</role-name>
</auth-constraint>
</security-constraint>
</web-app>
上下文配置位置
/WEB-INF/applicationContext-security.xml
过滤链氧
org.springframework.web.filter.DelegatingFilterProxy
过滤链氧
/*
org.springframework.web.context.ContextLoaderListener
用户角色
主管的角色
所有区域
/*
用户角色
问题似乎是:
<security-role>
<role-name>ROLE_USER</role-name>
</security-role>
<security-role>
<role-name>ROLE_SUPERVISOR</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>All areas</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>ROLE_USER</role-name>
</auth-constraint>
</security-constraint>
用户角色
主管的角色
所有区域
/*
用户角色
被定义
当我删除这个匿名授权的工作
(我在发布问题之前发现了这一点)
希望这对任何人都有帮助
美国