UsernamePasswordAuthenticationFilter 4

19.Authentication Flow

Authentication Flow : 인증의 흐름 Client Login Request UsernamePasswordAuthenticationFilter 가 수렴하여 username , password 를 담은 Authentication 토큰생성 AuthenticationManager 에게 Authentication 객체를 넘겨 처리 위임 AuthenticationManager는 인증 관리자로 적절한 AuthenticationProvider에게 넘기는 역할 만을 함 AuthenticationProvider 는 Authentication 객체를 받아 실제 인증 처리를 시작 AuthenticationProvider는 UserDetailsService에게 username 을 주어 User객체 요청 : loa..

17.SecurityContextHolder, SecurityContext

SecurityContext Authentication 의 보관소, 언제든 Authentication을 꺼내 사용할 수 있도록 제공되는 클래스이다. ThreadLocal 에 저장되어 아무 곳에서 참조가 가능하도록 설계됨 ThreadLocal 은 Thread 하나에 할당 된 저장소이다. 즉 Thread-Safe 하다. ThreadLocal은 인증 완료시 HttpSession 저장되어 Application 전반에서 참조가 가능하다. SecurityContextHolder SecurityContext를 감싸 저장하는 객체, 저장방법은 3가지이다. MODE_THREADLOCAL : 하나의 스레드 당 SecurityContext 를 할당 , default 값 MODE_INHERITABLETHREADLOCAL : ..

10.SessionManagementFilter, ConcurrentSessionFilter

세션 제어 필터인 SessionManagementFilter 와 ConcurrentSessionFilter 의 자세한 동작구조를 알아본다. SessionManagementFilter . 세션관리 : 인증 시에 사용자의 세션정보를 등록, 조회, 삭제 등의 세션 이력 관리 동시적 세션 제어 : 동일 계정으로 접속이 허용되는 최대 세션 수 제한 세션 고정 보호 : 인증할 때 마다 세션 쿠키를 새로 발급하여 공격자의 쿠키 조작 방지 세션 생성 정책 ConcurrentSessionFilter . 매 요청 마다 사용자의 세션 만료 여부 체크 만료되었을 경우 즉시 만료 처리시킴 session.isExpired() == true 일 경우 로그아웃 처리 즉시 오류 페이지 응답해 줌, "This session has be..

4.UsernamePasswordAuthenticationFilter

UsernamePasswordAuthenticationFilter? 로그인 처리, 인증기능 해주는 Filter이다. 실질적으로 사용자가 로그인을 하게되면, 인증처리가 이루어지는데 이 요청을 담당하여 인증처리를 하는 Filter가 UsernamePasswordAuthenticationFilter 이다. 흐름과 역할은, 분기점, 결과처리! 내부적으로 각각의 인증처리 역할에 따라 여러개의 클래스를 활용하게된다. 사용자가 인증을 시도 UsernamePasswordAuthenticationFilter가 요청을 받는다. AntPathRequestMatcher("/login") 가 요청 url이 로그인 url과 매칭되는지 검사한다. 매칭이 되면 다음단계 , 불일치하면 다른 Filter가 Chain 일치하면 Usern..