Using Spring Security for authentication and authorization
Spring Security is widely used to enable authentication and authorization, using many different mechanisms such as form-based logic, header-based login (Basic), and so on. In this application, we will be protecting the User Registration
microservice. Consider the following code:
<dependencies> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> ... </dependencies>
The preceding entries will import all the dependencies
related to Spring Security. Now, let's look at the configuration:
@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean public PasswordEncoder passwordEncoder() { return new SCryptPasswordEncoder(); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/users/reset...