로그인

    [Spring Security] 스프리 시큐리티를 이용한 회원가입, 로그인 구현

    [Spring Security] 스프리 시큐리티를 이용한 회원가입, 로그인 구현

    시큐리티 설정 파일을 만든다. @Configuration @EnableWebSecurity // 모든 요청 URL이 스프링 시큐리티의 제어를 받도록 만드는 어노테이션. // 내부적으로 SpringSecurityFilterChain이 동작하여 URL 필터가 적용된다. @RequiredArgsConstructor // Adapter를 상속함으로써 httpSecurity의 다양한 속성을 설정. public class WebSecurityConfig extends WebSecurityConfigurerAdapter { // defines which URL paths should be secured and not. @Override protected void configure(HttpSecurity http) t..

    [Spring Security] 기본 로그인 인증 로직

    [Spring Security] 기본 로그인 인증 로직

    이번에는 스프링 시큐리티에서 기본 HTTP 인증 로직이 어떻게 돌아가는지 알아보자. Basic HTTP Authentication 클라이언트로 요청이 들어오면 SecurityFilterChain에서 다음과 같은 동작이 일어난다. 1. 클라이언트가 인증되지 않은 요청을 한다. 2. 스프링 시큐리티의 FilterSecurityInterceptor는 AccessDeniedException 예외를 던지면서 요청을 거절한다. 3. 유저가 인증되지 않았기 때문에 ExceptionTranslationFilter는 인증에 필요한 과정을 실행한다. - AuthenticationEntryPoint의 구현체인 Basic AuthenticationEntryPoint는 WWW-Authenticate header를 보낸다. - ..