강의노트
-
[스프링 스큐리티] 인증 여부 검증(AuthenticationManager)강의노트/스프링 시큐리티 2020. 9. 14. 22:22
AuthenticationManager AuthenticationProvider 목록 중에서 인증 처리 요건에 맞는 AuthenticationProvider를 찾아 인증 처리를 위임한다. 부모 ProviderManager를 설정하여 AuthenticationProvider를 계속 탐색 할 수 있다. AuthenticationManager에 해당 요청을 처리할 AuthenticationProvider가 없는 경우 부모 AuthenticationManager에서 적합한 AuthenticationProvider를 탐색해서 처리한다. Form 인증 DaoAuthenticationProvider RememberMe 인증 RememberMeAuthenticationProvider Oauth 인증 Oauth 인증을 ..
-
[스프링 시큐리티] Authentication Flow강의노트/스프링 시큐리티 2020. 9. 14. 20:57
AuthenticationManager (ProviderManager) 사용할 수 있는 AuthenticationProvider 리스트를 멤버 변수로 가지고 있다. AuthenticationProvider 리스트에서 현재 인증에 적합한 AuthenticationProvider를 찾아서 인증을 위임한다. AuthenticationProvider (DaoAuthenticationProvider) UserDetailsService에 username을 매개변수로 전달하여 UserDetails 정보를 조회한다. UserDetailsService를 통해서 조회한 User가 존재하는 경우, 해당 User객체의 패스워드와 클라이언트에서 전달 한 패스워드를 일치하는지 검증한다. 패스워드가 일치하지 않으면 BadCrede..
-
[스프링 시큐리티] SecurityContext 객체 생성, 저장, 조회(SecurityContextPersistenceFilter)강의노트/스프링 시큐리티 2020. 9. 14. 20:11
SecurityContextPersistenceFilter SecurityContext 객체를 생성, 저장, 조회한다. Filter 리스트 중 2번째 위치한다. 인증 성공 후 Session에 저장하는 역활을 한다. Save SecurityContext HttpSecurityContextRepository 실질적으로 SecurityContext를 생성, 저장, 조회하는 클래스 동작 시나리오 익명 사용자가 접근 할 경우 새로운 SecurityContext 객체를 생성하여 SecurityContextHolder에 저장한다. AnonymousAuthenticationFilter에서 AnonymousAuthenticationToken 객체를 SecurityContext에 저장한다. 인증 사용자가 접근 할 경우 새..
-
[스프링 시큐리티] Authentication 객체 저장소(SecurityContext, SecurityContextHolder)강의노트/스프링 시큐리티 2020. 9. 14. 18:37
SecurityContext Authentication 객체가 저장되는 보관소로 필요 시 언제든지 Authentication 객체를 꺼내 쓸 수 있도록 제공되는 클래스 Authentication 객체 안에는 User 객체가 저장되어 있다. ThreadLocal에 저장되어 아무곳에서나 참조가 가능하다. ThreadLocal? Thread마다 고유하게 할당되는 저장소 인증이 완료되면 HttpSession에 저장되어 어플리케이션 전반에 걸쳐 전역적인 참조가 가능하다. SecurityContextHolder SecurityContext 객체를 감싸고 있는 클래스이다. SecurityContext 객체 저장 방식 MODE_THREADLOCAL : 스레드당 SecurityContext 객체를 할당 (default)..
-
[스프링 시큐리티] 인증 정보 저장 객체(Authentication)강의노트/스프링 시큐리티 2020. 9. 14. 18:14
인증 클라이언트가 자신이 주장하는 사용자와 같은 사용자인지를 확인하는 과정이다. 인증 시 id와 password를 담고 인증 검증을 위해 전달되어 사용된다. 인증 후 최종 인증 결과를 Authentication객체(User객체, 권한 정보)에 담고 SecurityContext에 저장되어 전역적으로 참조가 가능해진다. Authentication authentication = SecurityContextHolder.getContext().getAuthentication() 구조 principal : 사용자 아이디 또는 User 객체 credentials : 사용자 비밀번호 authorities : 인증된 사용자의 권한 목록 details : 사용자의 인증 정보 외에 부가 정보 Authenticated : 인..
-
[스프링 시큐리티] 필터 초기화와 다중 보안 설정강의노트/스프링 시큐리티 2020. 9. 14. 12:38
다중 설정 클래스 설정 클래스 별로 보안 기능이 각각 작동한다. 설정 클래스 별로 RequestMatcher를 설정한다. 설정 클래스 별로 필터가 생성된다. 다중 설정 클래스를 설정 할 경우 @Order 어노테이션을 통해서 어떤 보안 기능을 체크할지 설정해주어야 한다. (index 0부터 시작) Filter들과 RequestMatcher를 가진 SecurityFilterChain 객체가 각각의 보안 설정에 따라 생성되어진다. 각각의 생성된 SecurityFilterChain 객체들은 FilterChainProxy 빈에서 SecurityFilterChains 리스트 멤버 변수로 관리된다. 요청 처리 과정 요청이 들어오면 FilterChainProxy에서는 SecurityFilterChains 리스트에 있는..
-
[스프링 시큐리티] DelegatingFilterProxy & FilterChainProxy강의노트/스프링 시큐리티 2020. 9. 13. 00:25
ServletFilter WAS에서 톰캣이 올라가서 WAS에서 실행되는 필터이다. 요청을 받아서 Servlet에 전달하고, Servlet에서 응답을 받아서 클라이언트에 전달하는 역활을 수행한다. Servlet Container에서 생성되고 실행이 된다. 서블릿 필터는 스프링에서 정의된 빈을 주입해서 사용할 수 없다. Why? 서로 실행되는 컨테이너가 다르다. 인증/인가 처리는 스프링 컨테이너에 생성된 Filter를 통해서 처리된다. 실질적인 서블릿 필터가 DelegatingFilterProxy이다. // web.xml springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain ..
-
[스프링 시큐리티] CsrfFilter강의노트/스프링 시큐리티 2020. 9. 12. 23:43
CSRF (사이트 간 요청 위조) 웹 애플리케이션 취약점 중 하나로 사용자가 자신의 의지와 무관하게 공격자가 의도한 행동을 하여 특정 웹 페이지를 보안에 취약하게 한다거나 수정, 삭제 등의 작업을 하게 만드는 공격 방법을 의미한다. XSS와 SQL Injection과 비슷한데 XSS가 사용자가 특정 사이트를 신뢰한다는 점을 공격하는 거라면 CSRF는 특정 사이트가 사용자를 신뢰한다는 점을 공격하는 것이다. XSS : 악성 코드가 클라이언트에서 발생 CSRF : 악성 코드가 서버에서 발생 CsrfFilter 서버는 모든 요청에 대해서 랜덤으로 생성된 토큰을 클라이언트에 전달하고, 클라이언트는 매 요청 시마다 해당 토큰을 HTTP 파라미터 또는 헤더로 서버에 전달한다. 요청 시 전달 된 토큰 값과 서버에 저..