I am using spring security for authentication login. I want to pass the dynamic value in name and password but i don't want to use service layer, for this i am using web-service call in controller.
Here is my code :
<?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>
If you want to pass the dynamic value in name and password. You need to declare a bean that implement UserDetailsService interface. Then modify your xml to:
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="yourServiceBeanName">
</authentication-provider>
</authentication-manager>
You can use JDBC,File System or Memory to generate your name and password dynamically in your service.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.