Demand origin
Before our memory-based way, we constructed two accounts admin and user, for these two accounts have different roles in practical projects, such as the role of administrator roles and ordinary users, for different roles, then allow access method It will be different.
Coding ideas
For the question of powers of the different roles have different approaches, the main need to consider a few points:
(1) How to specify user-specified role
() Method, by assigning the role can roles AuthenticationManagerBuilder sample code:
auth.inMemoryAuthentication()
.withUser("admin")
.password(passwordEncoder().encode("123456"))
.roles("beijingAdmin","shanghaiAdmin");
The above example specified user admin, having beijingAdm