How to move username/passwords out of spring-security-context.xml?
spring, spring-mvc, spring-security
Solution
You can store the usernames and passwords in a separate .properties file.
<user-service id="userDetailsService" properties="users.properties"/>
users.properties should have the following format:
jimi=jimispassword,ROLE_USER,ROLE_ADMIN,enabled
bob=bobspassword,ROLE_USER,enabled
If you want to store it in a database, I would recommend you to read this article: http://www.mkyong.com/spring-security/spring-security-form-login-using-database/
Reference: Spring Security In-Memory Authentication
Problem
I am using Spring Security in one of my project. The web-app requires the user to login. Hence I have added few usernames and passwords in the spring-security-context.xml file as follows: ``` <authentication-manager> <authentication-provider> <user-service> <user name="user_1" password="password_1" authorities="ROLE_USER" /> <user name="user_2" password="password_2" authorities="ROLE_USER" /> </user-service> </authentication-provider> </authentication-manager> ``` My question is, how to move these username-password pairs to a different file (like some properties file) instead of keeping them in spring-security-context.xml? And how to read that file properties file?