Configuring the user credentials for REST API

We will use an in-memory store. The following snippet shows the configuration of a couple of users with different roles:

@Configuration
public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user1").password("{noop}user1-password").roles("ADMIN");
auth.inMemoryAuthentication()
.withUser("user2").password("{noop}user2-password").roles("USER");
}

}

We are configuring a couple of users for the APIuser1 and user2.

..................Content has been hidden....................

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