springframework/시작하자SpringSecurity

19.Authentication Flow

Jungsoomin :) 2020. 9. 22. 17:46

Authentication Flow : 인증의 흐름

 

  1. Client Login Request

  2. UsernamePasswordAuthenticationFilter 가 수렴하여 username , password 를 담은 Authentication 토큰생성

  3. AuthenticationManager 에게 Authentication 객체를 넘겨 처리 위임

  4. AuthenticationManager는 인증 관리자로 적절한 AuthenticationProvider에게 넘기는 역할 만을 함

  5. AuthenticationProvider Authentication 객체를 받아 실제 인증 처리를 시작

  6. AuthenticationProviderUserDetailsService에게 username 을 주어 User객체 요청 : loadUserByUsername(username)

  7. UserDetailsService가 유저정보를 DB에서 조회 : findById() 

  8. 존재하지 않는다면 UserNameNotFoundException 발생, UsernamePasswordAuthenticationFilter가 이를 받아 AuthenticationFailureHanlder 실행

  9. 유저정보가 DB에서 존재 UserDetails 타입의 User 객체 리턴

  10. AuthenticationProviderUserDetails 를 받아 UserDetails 의 password 값과  Authenticationcredential 속성 값을 검증

  11. 일치하지 않으면 BadCredentialException 발생, UsernamePasswordAuthenticationFilter가 이를 받아 AuthenticationFailureHanlder 실행

  12. password 까지 인증 되었으면 AuthenticationProvier UsernamePasswordAuthenticationToken 객체를 생성(Authentication 목차에 기술)  하여 AuthenticationManager 에게 리턴

  13. AuthenticationManagerUsernamePasswordAuthenticationToken 객체를 UsernamePasswordAuthenticationFilter 에게 리턴

  14. UsernamePasswordAuthenticationFilterSecurityContext(SecurityContextPersistenceFilter가 생성하는 듯함)UsernamePasswordAuthentionToken을 저장


Form Login 방식에서 AuthenticationMananger 가 선택하는 AuthenticationProvider

** DaoAuthenticationProvider는 FormLogin 인증 방식을 처리하는 구현체이다.