Spring security XML中的SpringSecurity3配置
我已经尝试通过XML配置Spring安全性一段时间了,但似乎无法让它正常工作。以下是我到目前为止的情况:Spring security XML中的SpringSecurity3配置,spring-security,Spring Security,我已经尝试通过XML配置Spring安全性一段时间了,但似乎无法让它正常工作。以下是我到目前为止的情况: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
[...]
<security:http auto-config="true">
<security:intercept-url pattern="/**" access="ROLE_USER" />
<security:http-basic />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
[???] <!-- What goes here? -->
</security:authentication-provider>
</security:authentication-manager>
</beans>
[...]
[???]
我找到的所有教程似乎都希望我将
放在占位符中,但NetBeans不会自动完成该元素。唯一类似于该元素的是任何用户服务
,据我所知,这是一个“抽象”元素
我只想配置一个内存中的用户和密码列表。在SpringSecurity版本3中如何实现这一点?
<security:authentication-manager>
<security:authentication-provider user-service-ref="userService">
</security:authentication-provider>
<bean id="userService" class="path.to.your.implementation.of.UserDetailsService" />
或者,您可以使用基本的内存内身份验证(而不是,以及):
官方spring文档始终是,imho.编写您自己的
org.springframework.security.authentication.AuthenticationProvider
,创建bean并向您的身份验证管理器提供参考:
<authentication-manager>
<authentication-provider ref="com.example.CustomAuthenticationProvider"/>
</authentication-manager>
或者,您可以只向相关机构提供用户名和密码(我在模拟时使用此选项)
谢谢,但正如我在问题中解释的那样,
用户服务
在这个位置上似乎不是一个有效的元素。我认为这可能是Spring Security中一个相对较新的变化。
<authentication-manager>
<authentication-provider ref="com.example.CustomAuthenticationProvider"/>
</authentication-manager>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="test" password="test" authorities="ROLE_AUTHENTICATED" />
</user-service>
</authentication-provider>
</authentication-manager>