Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 프로그래머스 최댓값 만들기(2)
- 객체지향
- 배열 만들기1
- 프로그래머스 n의 배수 고르기
- 프로그래머스
- 문자열 정렬하기 (1)
- Til
- Error installing cocoapods
- 프로그래머스 n번째 원소까지
- ruby설치
- 스페인어
- 프로그래머스 주사위 게임1
- 조건에 맞게 수열 변경하기 3
- array
- 프로그래머스 자동커밋
- swift
- 스파르타코딩캠프
- continue
- 프로그래머스 문자열 정렬하기 (1)
- Break
- 스파르타 코딩클럽 내일배움캠프
- n번째 원소까지
- cocoapods 설치 오류
- 연산자
- 프로그래머스 조건에 맞게 수열 변경하기 3
- 프로그래머스 암호 해독
- 프로그래머스 문자열 붙여서 출력하기
- 주사위 게임1
- 문자열 붙여서 출력하기
- 프로그래머스 배열 만들기1
Archives
- Today
- Total
dev._.note
[SPRING] Spring Security Filter 본문
Spring Security?
Spring Security는 스프링 기반의 어플리케이션 보안을 담당하는 프레임워크.
Spring Security를 사용하면 사용자 인증, 권한, 보안처리를 간단하지만 강력하게 구현 할 수 있다.
Filter 기반으로 동작하기 때문에 Spring MVC와 분리되어 동작한다.
- 인증(Authentication) 접근한 유저를 식별하고, 애플리케이션에 접근할 수 있는지 검사하는 것
- 접근 주체(Principal) 보안 시스템이 작동되고 있는 애플리케이션에 접근하는 유저
- Credentials 특정리소스에 접근하려는 사용자가 인증을 위해 제공하는 비밀번호
- 인가(Authorization) 인증된 유저가 애플리케이션의 기능을 이용할 수 있는지 검사하는 것.
- 권한 Authorities 인증된 유저가 가진 권한 목록
Spring Security Filter Chain
@web.xml
- DelegatingFilterProxyRegistrationBean이 DelegatingFilterProxy필터클래스를springSecurityFilterChain이라는 이름의 Filter로 등록
- legacy project에서는 web.xml에서 DelegatingFilterProxy필터 등록시 application-context에 빈으로 등록됨.
- Servler이전 FilterChain실행중, springSecurityFilterChain 에 도달하면, DelegatingFilterProxy클래스는 FilterChainProxy 클래스에게 처리를 위임.
- FilterChainProxy는 AuthenticationFilter 들을 리스트로 보관하고 있는 클래스
- FilterChainProxy의 AuthenticationFilter들을 순서대로 실행.
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>
</filter-mapping>
Filter Chain 상세
7.3 Filter Ordering
- ChannelProcessingFilter because it might need to redirect to a different protocol
- *SecurityContextPersistenceFilter, so a SecurityContext can be set up in the SecurityContextHolder at the beginning of a web request, and any changes to the SecurityContext can be copied to the HttpSession when the web request ends (ready for use with the next web request)
- Authentication객체를 보관하는 SecurityContext객체를 생성해주는 필터
- ConcurrentSessionFilter, because it uses the SecurityContextHolder functionality but needs to update the SessionRegistry to reflect ongoing requests from the principal
- Authentication processing mechanisms - SecurityContextHolder can be modified to contain a valid Authentication request token.
- *UsernamePasswordAuthenticationFilter AbstractAuthenticationProcessingFilter 를 상속.
- CasAuthenticationFilter
- BasicAuthenticationFilter
- etc
- SecurityContextHolderAwareRequestFilter, if you are using it to install a Spring Security aware HttpServletRequestWrapper into your servlet container
- HttpServlet 인증 방식에 따라 ServletRequest객체를 재구성하는 필터
- RememberMeAuthenticationFilter, so that if no earlier authentication processing mechanism updated the SecurityContextHolder, and the request presents a cookie that enables remember-me services to take place, a suitable remembered Authentication object will be put there
- AnonymousAuthenticationFilter, so that if no earlier authentication processing mechanism updated the SecurityContextHolder, an anonymous Authentication object will be put there
- 이 필터에 올 때까지 인증 객체가 생성되지 않으면 익명의 사용자가 보낸 것으로 판단하고 처리한다. (Authentication 객체를 새로 생성)
- *ExceptionTranslationFilter, to catch any Spring Security exceptions so that either an HTTP error response can be returned or an appropriate AuthenticationEntryPoint can be launched
- 앞선 필터 처리 과정에서 인증 예외(AuthenticationException) 또는 인가 예외(AccessDeniedException)가 발생한 경우, 해당 예외를 캐치하여 처리하는 필터 (모든 예외를 다 이 필터에서 처리하는 건 아님)
- *FilterSecurityInterceptor, to protect web URIs and raise exceptions when access is denied
- 인가(Authorization)를 결정하는 AccessDecisionManager에게 접근 권한이 있는지 확인하고 denied인 경우 예외를 던짐.
기타 filters
- WebAsyncManagerIntegrationFilter 비동기 요청에 대해 Authentication객체를 사용할 수 있도록 처리해주는 필터
- SessionManagementFilter 세션 변조 공격 방지 (SessionId를 계속 다르게 변경해서 클라이언트에 내려준다) 유효하지 않은 세션으로 접근했을 때 URL 핸들링.
- 하나의 세션 아이디로 접속하는 최대 세션 수(동시 접속) 설정
- 세션 생성 전략 설정
- HeaderWriterFilter 응답 Header를 작성하는 필터
- CsrfFilter csrf 공격을 방어하는 필터
- LogoutFilter 로그아웃 요청을 처리하는 필터
- RequestCacheAwareFilter 인증 후, 원래 Request 정보로 재구성하는 필터
How Spring Security Filter Chain works
security filter chain은 강력하고, 유연해서 처리할 필터의 종류와 순서를 커스터마이징 할 수 있다.
'Dev > SPRING' 카테고리의 다른 글
[SPRING] Springboot (0) | 2023.03.06 |
---|---|
[SPRING] AOP(Aspect Oriented Programming) 관점 지향 프로그래밍 (0) | 2023.02.27 |
[SPRING] 스프링 개요 (1) | 2023.02.26 |
[SPRING] Transaction 선언 (0) | 2023.02.25 |