Today I Learned/Spring Boot

시큐리티 기본 Authentication

Malachai Lee 2022. 4. 24. 19:30

 

 

1.

 로그인 요청의 내용을 가진 Http request는 username과 password를 포함한 body를 가진 채 AuthenticationFilter로 보내진다.

 

2.

 AuthenticationFilter는 username과 password를 이용해 UsernamePasswordAuthenticationToken을 생성한다.

 

3.

 만들어진 UsernamePasswordAuthenticationToken을 AuthenticationManager에게 전송한다.

 

4. 5. 6.

 AuthenticationManager는 username을 UserDetailsService에게 전송하여 DB에서 해당 유저 이름을 검색한다.

 

7. 8.

 만약 유저가 존재한다면 AuthenticationManager에게 돌려준다. DB에서 가져온 password가 AuthenticationManager가 가지고있는 encrypted password와 동일하다면, UsernamePasswodAuthenticationToken을 이용해 Authentication이라는 객체를 생성한다.

 

9.

 세션 내에 위치한 SecurityContext에 Authentication 객체를 저장한다.