스터디-Spring

[스프링 시큐리티] 스프링 시큐리티 설정하기

일태우 2022. 1. 7. 14:08
반응형

스프링 웹 시큐리티 설정 추가

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .mvcMatchers("/", "/info").permitAll()
                .mvcMatchers("/admin").hasRole("ADMIN")
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .and()
            .httpBasic();
    }
}
  • authorizeRequest() -어떻게 요청들을 인가할지
  • formLogin() - 폼 로그인 사용하겠다
  • httpBasic() - Basic Authentication 사용

해결되지 않은 문제

  1. 아직 패스워드가 로그에 남음
  2. Admin처리가 안됨
반응형