Spring (8) 썸네일형 리스트형 SpringSecurity(아키텍처 정리) 초기화 과정부터 한번 살펴보자 SpringSecurity가 초기화 되면서 사용자가 설정한 Api 구성대로 HttpSecurity클래스가 필터들을 생성한다. 이후에 생성된 필터들은 WebSecurity 클래스로 전달하게 된다 그리고 다시 FilterChainProxy에게 빈객체를 생성자로 생성하여 WebSecurity에서 전달받은 Filter들을 FilterChainProxy 에게 전달한다 그러면 FilterChainProxy 는 사용자가 설정한 2개의 설정 클래스들을 가지게 된다. DelegatingFilterProxy 이클래스는 servlet필터 인데 이클래스도 초기화 될때 이미 FilterChainProxy 빈으로 생성된다 DelegatingFilterProxy 는 springSecurityFilte.. SpringSecuirty(AccessDecisionManager,AccessDecisionVoter) 인증 정보, 요청정보, 권한정보를 이용해서 사용자의 자원접근을 허용할 것인지 거부할 것인지를 최종 결정하는 주체 여러 개의 Voter 들을 가질 수있으며 Voter 들로부터 접근허용, 거부, 보류에 해당하는 각각의 값을 리턴받고 판단 및 결정 최종 접근 거부 시 예외 발생 접근결정의 세가지 유형 AffirmativeBased 여러개의 Voter 클래스 중 하나라도 접근 허가로 결론을 내면 접근 허가로 판단한다 ConsensusBased 다수표(승인 및 거부)에 의해 최종 결정을 판단한다 동수일경우 기본은 접근허가이나 allowIfEqualGrantedDeniedDecisions 을 false 로 설정할 경우 접근거부로 결정된다 UnanimousBased 모든 보터가 만장일치로 접근을 승인해야 하며 그렇지.. SpringSecurity(Authorization,FilterSecurityInterceptor) 이전까지 인증에 대하여 계속 공부해봤다 이제인가 처리를 한번 공부해보자 한다 인가는 말그대로 사용자가 로그인 했을때 서버자원에 접근할수 잇는 자격이 있는지 여부를 판단하는게 인가처리 라고 할수있다. 그래서 SprginSecurity는 Authentication과 Authorization 두개를 처리하도록 되어 있다. 위에 그림을 보면 사용자가 서버 자원에 접근하려 할때 그 사용자가 Authenticated 먼저 인증을 받았는지 안받았는지 확인을 하게된다 이후에 Authorization 에서 해당자원에 설정된 권한에 충분한 자격이 있는지 권한 심사를 하게된다. 스프링 시큐리티가 지원하는 권한계층을 살펴보자 웹 계층 URL 요청에 따른 메뉴 혹은 화면단위의 레벨보안 사용자가 user라는 경로로 자원에 접근하.. SpringSecurity(AuthenticationManager) AuthenticationProvider 목록중에서 인증 처리 요건에 맞는 AuthenticationProvider 를 찾아 인증처리를 위임한다 부모ProviderManager 를 설정하여 AuthenticationProvider를 계속 탐색 할 수 있다 AutheticationManager는 인증처리를 하는 첫번째 클래스이다. 사용자의 아이디와 패스워드를 Authentication(인증객체)에 담아서 AutheticationManager 에게 전달함으로써 AutheticationManager는 전반적으로 인증에 관해 모든 처리를 관리한다 AutheticationManager 인터페이스고 구현체가 ProviderManager이다 ProviderManager가 초기화 되면서 Provider타입의 객체들을 .. SpringSecurity(SecurityContextPersistenceFilter) SecurityContext 객체의 생성, 저장, 조회 익명 사용자(Anonymous) 새로운 SecurityContext객체를 생성하여 SecurityContextHolder 에 저장 AnoymousAuthenticationFilter 에서 AnonymousAuthenticationToken 객체를 SecurityContext에 저장 인증시 새로운 SecurityContext 객체를 생성하여 SecurityHolder 에 저장 UsernamePasswordAuthenticationFilter에서 인증 성공 후 SecurityContext에 UsernamePasswordAuthentication 객체를 SecurityContext에 저장 인증이 최종 완료되면 Session에 SecurityContext .. SpringSecurity(SecurityContextHolder,SecurityContext) SecurityContext Authentication 객체가 저장되는 보관소로 필요시 언제든지 Authentication 객체를 꺼내어 쓸 수 있도록 제공되는 클래스 Threadlocal에 저장되어 아무곳에서나 참조가 가능하도록 설계함 인증이 완료되면 HttpSession에 저장되어 어플리케이션 전반에 걸쳐 전역적인 참조가 가능하다 Threadlocal : 스레드마다 고유하게 할당되는 저장소가 있는데 스레드와 스레드가 공유되지 않고 각 할당된 저장소에게만 공유가 된다. SecurityContextHolder SecurityContext 객체 저장 방식 Mode_THREADLOCAL: 스레드당 SecurityContext 객체를 할당, 기본값 Mode_INHERITABLETHREADLOCAL: 메인 스레.. SpringSecurity(Authentication) 그전시간에 계속 해서 Authentication(인증)에 대해서 언급을 했다 그러면 도대체!! Authentication(인증)이 뭐냐!! 이제 알아보자 ! Authtication은 말그대로 너가 누구냐! 당신은 누구냐!를 증명하는것이다 사용자의 인증 정보를 저장하는 토큰개념 인증시 id와password를 담고 인증 검증을 위해 전달되어사용된다 인증 후 최종 인증 결과(user 객체 권한정보) 를 담고 SecurityContext에 저장되어 전역적으로 참조가 가능하다 Authentication authentication = SecurityContextHolder.getContext().getAuthentication() // 인터페이스 구조(속성) principal : 사용자 아이디 혹은 User 객체를.. SpringSecurity(필터초기화 다중보안설정) 설정 클래스 별로 보안 기능이 각각 작동( SecurityConfigu1과 SecurityConfigu2가 따로 실행되도록 지원하게 된다) 설정 클래스 별로 RequestMatcher 설정 http.antMatcher("/admin/**") (admin으로 접근할때는 첫번째 설정클래스의 보안클래스가 실행된다 / 다른 url로 요청시 두번째 설정 클래스가 실행된다.) 설정클래스 별로 필터가 생성 ( 초기화 할때 각각의 필터가 초기화 된다) 초기회 되면서 생성되었던 필터가 SecurityFilterChain 이라는 클래스 안에 속하게된다 antMatcher("/admin/**") 설정했던 url 정보를 RequestMacher 타입의 변수로 담긴 클래스의 객체가 생성된다(SecurityFilterChain).. 이전 1 다음