
사용자가 로그인(인증) 시도.
UsernamePasswordAuthenticationFilter(폼인증방식 필터) 작동
2-1 사용자의 요청을 받아서 인증(Authentication[id+password 정보]) 객체를 생성
2-2 AuthenticationManager 클래스에 인증처리를 맡긴다.
authenticate(Authentiation) 인증객체를 AuthenticationManager에게 넘기는 일까지 UsernamePasswordAuthenticationFilter 얘가 한다.
AuthenticationManager는 인증 객체를 전달 받는다
3-1 AuthenticationManager는 인증의 전반적인 관리를 한다.
-- 실제 인증은 하지 않아 AuthenticationProvider에 위임하는 것이 얘 일.
-- 검증에는 관여하지 않는다는 뜻
AuthenticationProvider 얘까 검증한다
-- id+password를 검증한다.
-- loadUserByUsername(username) 호출해서 유저 객체 전달 UserDetailsService에.
UserDetailsService(인터페이스)에 사용자 객체를 요청
5-1 UserDetailsService가 유저 객체를 조회한다
5-2 findbyId() --- 유저 객체 조회, 성공하면 UserDetails 타입으로 반환
5-3 DB에 계정 정보가 있으면 유저 객체가 생성되어 리턴
5-4 존재하지 않으면 not found 예외 발생시켜UsernamePasswordAuthenticationFilter가 예외 처리를 한다
즉시 인증 실패라는 뜻.
failure handler에서 실패 후속 처리.
아이디 검증된(계정정보가 있는) 경우
6-1 AuthenticationProvider 에게 리턴하는데
UserDetails 타입으로 user정보를 반환
6-2 패스워드 검증 반환받은 UserDetails 타입의 password와
사용자가 입력한 password를 일치여부를 비교한다.
[ 일치하지 않으면 bad credential 에러 발생 -> 인증 실패 ]
6-3 id + password가 일치하면 AuthenticationProvider는 인증객체를 만든다.

6-4 최종적으로 성공한 인증객체를 담은 인증 객체 생성 후 AuthenticaionManager에게 반환한다.
6-5 AuthenticaionManager는 최종인증 객체를 다시 필터에 전달하고
6-6 필터는 이 인증 객체를 SecurityContext에 저장한다.
요약