[英]Login form based spring 3 security
我正在使用Spring Security進行身份驗證登錄。 我想在名稱和密碼中傳遞動態值,但是我不想使用服務層,為此我在控制器中使用了Web服務調用。
這是我的代碼:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
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-3.1.xsd">
<global-method-security pre-post-annotations="enabled" />
<http pattern="/auth/logout.html" security="none"/>
<http pattern="/css/**" security="none" />
<http pattern="/js/**" security="none" />
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/accessdenied" access="permitAll" />
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
<form-login login-page="/login" default-target-url="/suburb_analyser" authentication-failure-url="/accessdenied" />
<logout logout-success-url="/logout" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user name="j@hotsal.com.au" password="mor55eover" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
如果要在名稱和密碼中傳遞動態值。 您需要聲明一個實現UserDetailsService接口的bean。 然后將您的xml修改為:
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="yourServiceBeanName">
</authentication-provider>
</authentication-manager>
您可以使用JDBC,文件系統或內存在服務中動態生成您的名稱和密碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.