Chap 4. 스프링 시큐리티
스프링 인 액션(5판) 챕터 4장을 요약한 내용 입니다.
스프링 시큐리티 구성하기
의존성 추가하기
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>스프링 시큐리티 기본 구성 클래스
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/design", "/orders")
.access("hasRole('ROLE_USER')")
.antMatchers("/", "/**").access("permitAll")
.and()
.formLogin()
.loginPage("/login")
.and()
.logout()
.logoutSuccessUrl("/")
.and()
.csrf()
.ignoringAntMatchers("/h2-console/**")
.and()
.headers()
.frameOptions()
.sameOrigin();
}
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(encoder());
}
}인메모리 사용자 스토어
JDBC 기반의 사용자 스토어
LDAP 기반 사용자 스토어
비밀번호 비교 구성하기
LDAP 기반 사용자 스토어
사용자 인증의 커스터마이징
웹 요청 보안 처리하기
웹 요청 보안 처리하기
CSRF 공격 방어하기
요약
Last updated