chh78151.log
로그인
chh78151.log
로그인
Spring security 뜯어보자!(6) - Authentication Flow
야크르드
·
2023년 7월 23일
팔로우
0
spring security
spring-security
목록 보기
7/8
Authentication Flow
사용자가 로그인 요청을 보냄
UsernamePasswordAuthenticationFilter진입 후 해당 Request에 담긴 정보로 인증 전 AuthenticationToken 발급
Authentication Token 발급
발급된 인증 전 Token을 가지고 AuthenticationManager를 통해 적절한 Provider로 인증 위임
Manager에서 결정된 Provider에서 유저에 대한 유효성 검증
supports메소드를 통해 적절한 provider인지 확인 후 해당 provider.authenticate(authentication)을 통해 해당 provider에 인증을 위임
Provider는 UserDetailsService를 이용하여 loadUserByUsername을 통해 해당 user에 존재여부 확인 후 password 검사
해당 class에는 custom provider로 검증이 된다.
인증 절차가 끝나면 해당 요청에 맞는 UserDetails 객체를 반환한다.
반환 받은 UserDetails 정보와 authorities를 가지고 인증 된 AuthenticationToken을 생성
생성된 토큰을 SecurityContext에 저장
해당 SecurityContext를 Session에 저장하고 SecurityContextHolder를 초기화
인증된 사용자는 SuccessHandler로 보내 인증 완료 처리
마치며
이번장에서는 security의 전반전인 Authenticaion Flow에 대해 살펴보았다.
다음장에서는 여기서 flow에 사용된 AuthenticationManager와 provider에 대해 살펴보겠다.
야크르드
개발을 좋아하는 백엔드 개발자
팔로우
이전 포스트
Spring security를 뜯어보자!(5) - SecurityContextPersistenceFilter, SecurityContextHolderFilter
다음 포스트
Spring security 뜯어보자!(7) - AuthenticationManager
0개의 댓글
댓글 작성