AuthenticationManager 5

21.AuthenticationProvider

AuthenticationProvider 실질적으로 인증처리를 하는 핵심 클래스로 Interface 이다. AuthenticaionProvider를 구현하여 서비스에 맞는 인증방식을 만드는 것이 주를 이룬다. 재정의 할 메서드 boolean support(authentication) : 조건의 기준 검사. Authentication authenticate(authentication) : 실질적 인증처리를 위한 검증 매개 값으로는 username , password 를 가진 Authentication 객체를 가진다. 흐름 구조를 알면 메서드 재정의 방식을 이해할 수 있을듯 하다. authenticate(authentication) 에서 username 검증을 위해 UserDetailsService 호출 ,..

20.AuthenticationMananger를 구현한 ProviderManager

ProviderManager 는 AuthenticationManager 의 구현객체이다. 동작 구조 인증을 요구하는 Filter( UsernamePasswordAuthenticationFilter, RemeberMeAuthenticationFilter...) 에서 인증 요청을 받게되면 AuthenticationProvider의 구현체인 ProviderManager가 작동 ProviderManager 는 해당 인증방식 (Form Login, Remember Me , Oauth..) 에 따라서 자신이 가지고 있는 AuthenticationProvider 중 알맞은 AuthenticationProvider 를 찾는다. (DaoAuthenticationProvider , RememberMeAuthenticati..

19.Authentication Flow

Authentication Flow : 인증의 흐름 Client Login Request UsernamePasswordAuthenticationFilter 가 수렴하여 username , password 를 담은 Authentication 토큰생성 AuthenticationManager 에게 Authentication 객체를 넘겨 처리 위임 AuthenticationManager는 인증 관리자로 적절한 AuthenticationProvider에게 넘기는 역할 만을 함 AuthenticationProvider 는 Authentication 객체를 받아 실제 인증 처리를 시작 AuthenticationProvider는 UserDetailsService에게 username 을 주어 User객체 요청 : loa..

16.Authentication

인증, Authentication 스스로 누구인지 증명하는 것이다. Authentication 객체는 사용자의 인증 정보를 담는 Token 개념이다. (UsernameAuthenticationToken , AnonymousAuthenticationToken , RememberMeAuthenticationToken...) 인증 시의 id , password를 담아 인증 검증을 위해 전달되어 사용된다. 인증 후 최종 Authentication 객체에는 사용자 정보를 담은 User 객체와 권한정보인 Authority가 들어있다. Authentication 객체는 SecurityContext에 저장되어 전역적으로 참조가 가능 Authentication authentication = SecurityContextH..

4.UsernamePasswordAuthenticationFilter

UsernamePasswordAuthenticationFilter? 로그인 처리, 인증기능 해주는 Filter이다. 실질적으로 사용자가 로그인을 하게되면, 인증처리가 이루어지는데 이 요청을 담당하여 인증처리를 하는 Filter가 UsernamePasswordAuthenticationFilter 이다. 흐름과 역할은, 분기점, 결과처리! 내부적으로 각각의 인증처리 역할에 따라 여러개의 클래스를 활용하게된다. 사용자가 인증을 시도 UsernamePasswordAuthenticationFilter가 요청을 받는다. AntPathRequestMatcher("/login") 가 요청 url이 로그인 url과 매칭되는지 검사한다. 매칭이 되면 다음단계 , 불일치하면 다른 Filter가 Chain 일치하면 Usern..