Spring Boot + Spring Security: authentication information based on memory - Part 3

Demand origin

       Above we simply experience the next Spring Security, but now only one user information, we hope here can configure multiple account information, under this section mainly explains how to configure authentication information in memory.

 

Coding ideas

       We need to initialize our authentication information in memory, then the need is to rewrite configure method WebSecurityConfigurerAdapter class:

configure(AuthenticationManagerBuilder auth)

Then () method to specify the authentication object information inMemoryAuthentication auth:

auth.inMemoryAuthentication().withUser("admin").password("123456");

       In summary, first need to define a configuration class inherits WebSecurityConfig WebSecurityConfigurerAdapter; then configure inside rewriting method; last used Authen

Guess you like

Origin blog.csdn.net/linxingliang/article/details/104608795