How to move username/passwords out of spring-security-context.xml?

前端 未结 6 1434
一个人的身影
一个人的身影 2020-12-16 23:01

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 fi

6条回答
  •  心在旅途
    2020-12-16 23:28

    You can store the usernames and passwords in a separate .properties file.

     
    

    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

提交回复
热议问题