Spring Security 인증 처리 흐름

- 로그인 request
▶ Username & Password를 포함한 request ➡ 애플리케이션에 전송
▶ UsernamePasswordAuthenticationFilter 가 해당 요청을 받음
- UsernamePasswordAuthenticationFilter 에 의해 UsernamePasswordAuthenticationToken 생성
▶ 아직 인증 ❌
- AuthenticationManager 에 Authentication 전달
- 생성된 Authentication ➡ AuthenticationManager 에 전달
▶ AuthenticationManager : 인증처리를 총괄하는 매니저 역할
▶ ProviderManager : AuthenticationManager 에 의해 구현됨 [인증 작업 총괄 ]
- AuthenticationProvider 는 ProviderManager 로 부터 Authentication 을 전달받음 ➡ UserDetailsService 를 이용해 UserDetails 조회
- UserDetailsService 는 저장소에서 사용자의 크리덴션을 포함한 사용자 정보 조회
- 조회된 크리덴션을 기반으로 UserDetails 생성
- UserDetails 를 다시 AuthenticationProvider 에 전달
- PasswordEncoder 를 이용해 UserDetails 에 포함된 암호화된 Password와 인증을 위한 Authentication 안에 포함된 Password가 일치하는지 검증
- 인증된 Authentication 을 ProviderManager에 전달
- 인증된 Authentication을 다시 UsernamePasswordAuthenticationFilter 에 전달
- SecurityContextHolder 를 이용해 SecurityContext 에 인증된 Authentication 을 저장