In-memory authentication

In-memory authentication is useful in scenarios where developers don't want to waste their time in configuring the databases or writing a custom implementation of the UserDetailsService. The following configuration shows how to add the UserDetailsService for in-memory authentication:

<user-service id="userDetailsService"> 
   <user name="abc" password="abc" authorities="ROLE_ADMIN" /> 
   <user name="xyz" password="xyz" authorities="ROLE_USER,ROLE_ADMIN" /> 
</user-service> 

We already used this in both our applications. Spring also supports loading the credentials and their assigned roles from an external properties. To use the properties, the preceding configuration has to be updated as follows:

<user-service id="userDetailsService"   
  properties="myusers.properties"/> 

The myusers.properties file contains the credential details in the following format:

username=password,grantedAuthority[,grantedAuthority][,enabled|disabled] 

Using the preceding format, our myusers.properties file will contain the following details:

abc=abc,ROLE_USER,enabled 
xyz=xyz,ROLE_USER,ROLE_ADMIN,enabled 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.30.253