Spring
[Spring-Security]HttpSecurity
codinglog
2020. 7. 21. 14:41
HttpSecurity는 네임 스페이스 구성에있는 Spring Security의 XML <http> 요소와 유사합니다. 특정 http 요청에 대해 웹 기반 보안을 구성 할 수 있습니다. 기본적으로 모든 요청에 적용되지만 requestMatcher (RequestMatcher) 또는 기타 유사한 메소드를 사용하여 제한 할 수 있습니다.
@Configuration
@EnableWebSecurity
public class FormLoginSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
}
}
반응형