[ODOP] 90일차 - Authentication Provider
![[ODOP] 90일차 - Authentication Provider](/content/images/size/w1200/2023/08/-----2023-08-01----10.29.26-23.png)
- 인증 처리를 할 때 가장 핵심적인 역할을 하는 클래스
![](https://blog.pollra.com/content/images/2023/08/-----2023-09-01----4.48.50.png)
Filter 에서 기본적인 인증 데이터가 묶여 Authentication 객체로 넘어오고, 인증에 대한 처리를 맏게 될 ProviderManager(AuthenticationProvider 를 구현한 구현체) 가 정해지면 해당 로그인 기능을 실행하게 된다
-
id 가 실제로 존재하는지 검사하는 UserDetailsService
-
password 가 실제로 일치 하는지 검사하고 BadCredentialException 을 발생시킨다
우리가 기본적으로 사용자의 암호를 저장하기 위해서는 PasswordEncoder 를 통해 암호화된 비밀번호를 저장하는데 여기서 일치 검사할 때 사용하는 것은 PasswordEncoderFactories 에서 생성하고 있는 PasswordEncoder 를 사용하게 된다.
아래의 이미지는 DaoAuthenticationProvider(Form 인증 방식 에서 동작하는 Provider) 가 사용하고 있는 PasswordEncoder 를 set 해주고 있는 부분
잘 보면 UserDetailService, UserDetailsPasswordService 라는 것을 확인해 볼 수 있는데 아마 확장성 때문이 아닐까 싶다.
다음은 AuthenticationProvider 의 코드 전문
![](https://blog.pollra.com/content/images/2023/08/-----2023-09-01----4.50.23.png)
-
authenticate
인증 처리를 위한 동작을 명시해둔 인터페이스
-
supports
해당 authentication 의 타입이 해당 Provider 에서 수행할 수 있는지 에 대해 boolean 값으로 나타내는 함수