
/User request/
인증 필터(인증 생성) - 제공 매니저 - 인증 제공자
유저정보 서비스(유저정보 생성) 크레덴셜 저장소를 호출하여
인증 제공자(확인된 인증 생성) - 제공 매니저 - 인증 필터
시큐리티 컨텍스트(검증된 인증 저장)
1. UserPasswordAuthenticationFilter(필터)
HTTP 기반의 인증 요청을 처리
AbstractAuthenticationProcessingFilter상속하여doFilter()실행
Authentication구현->AbstractAuthenticationToken상속 ->
UserPasswordAuthenticationToken(Uesername, Password)생성검증된 인증을 마지막으로
SecurityContext에 저장 ->HttpSession에 저장
2. ProviderManager(제공 매니저)
AuthenticationManager의 구현 클래스
받은List<AuthenticationProvider>중 인증 객체를 처리할 수 있는
AuthenticationProvider를 찾아authenticate()를 실행시킴
인증 후 Token의Credentials를 바로 삭제
3. AuthenticationPovider(인증 제공자)
authenticate()를 실행,Authentication의 Password와 이름으로 호출한UserDetails의 Password를 대조하여 인증UserDetails의 비밀번호는 해시화된 형태로
대조 전 Authentication의 Password도 PasswordEncoder로 인코팅해서 비교
인증 성공 시 UserPasswordAuthenticationToken 생성
- Principal: Username or UserDetails
- Credentials: Password
- GrantedAuthority: SimpleGrantedAuthority로 컬렉션 구현
메서드 실행 흐름
//DaoAuthenticationProvider는 AuthenticationProvider의 구현 클래스 authenticate() retrieveUser() additionalAuthenticationChecks() createSuccessAuthentication() 인증된 Authentication을 ProviderManager에게 리턴
4. UserDetailservice(유저정보 서비스)
Credential Storage
UserDetails
5. SecurityContext
SecurityContext는 인증된 Authentication 객체를 저장하는 컴포넌트
SecurityContextHolder에 의해 저장됨
SecurityContext에 Authentication이 채워져 있다면 인증된 사용자로 간주