O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring Spring Security

Now, we will configure Spring Security authentication and authorization by creating a Spring Security configuration class as follows:

@EnableWebSecuritypublic class SpringMvcSecurityConfig extends WebSecurityConfigurerAdapter {    @Autowired  PasswordEncoder passwordEncoder;    @Override  protected void configure(AuthenticationManagerBuilder auth)         throws     Exception {    auth    .inMemoryAuthentication()    .passwordEncoder(passwordEncoder)    .withUser("user").password(passwordEncoder.encode("user@123"))    .roles("USER")    .and()    .withUser("admin").password(passwordEncoder.    encode("admin@123")            ).roles("USER", "ADMIN");  }    @Bean  public PasswordEncoder passwordEncoder() {      return new BCryptPasswordEncoder();  }    @Override protected void ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required