UserDetailsService

로그인 관련 실습을 하며 UserDetailsServiceUserDetails 를 구현해 사용했다.

근데 이 클래스가 어디서 어떻게 쓰이는지 궁금해 한번 찾아봤다.

UsernamePasswordAuthenticationFilter

스프링 시큐리티 필터체인에서 중간쯤에 위치한 필터다.

Screenshot 2024-04-16 at 20.55.00.png

역할은 사용자의 이름과 비밀번호를 검증하는 것이다.

UsernamePasswordAuthenticationFilter authenticates the username and password. https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/form.html

필터의 구조는 다음과 같다.

https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/form.html

https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/form.html

HttpServletRequest 에서 유저 이름과 비밀번호를 추출해 토큰을 생성한다. 이 토큰의 검증을 AuthenticationManager 에게 위임한다.

성공하면, 성공 정책에 따라 행동하고, 실패하면 실패 정책에 따라 행동한다.

AuthenticationManager