Using Spring Security for authentication and authorization
This web application has used Spring Security to authenticate users and to authorize them to submit comments. The Maven Spring Security starter needs to be specified as follows to enable Spring Security in the web application:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> </dependencies>
The following is the Spring Security configuration:
@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserService userDetailService; @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/h2-console/**"); } @Override protected void configure(HttpSecurity http) throws Exception { http.formLogin() .and() .logout() ...