maven

1
2
3
4
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>

config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and().formLogin().loginProcessingUrl("/login").permitAll()
                .and().csrf().disable();
    }
}
1
2
spring.security.user.name=admin
spring.security.user.password={bcrypt}$2a$10$io1baOv5SiP2G0DR.Dye.OQjtj1W8Aba31pGecyYdxgoXLkLjdfm.