Spring Security - Filters ( DelegatingFilterProxy, FilterChainProxy )

이번 글에서는 Spring Security Filter Chain 에 대해서 정리를 하려고 한다. https://spring.io/guides/topicals/spring-security-architecture Spring Security web infrastructure 는 Servlet filter 기반이다. 아래의 이미지를 보면, http request 가 어떻게 처리 될 지 명백하게 이해할 수 있을것이다. Client 는 Application 으로 요청을 보낸다. 그리고 해당 요청은 어떤 filter 들과 어떤 servlet 이 적용되야 하는지 request URI 에 따라서 판별된다. 최대 하나의 servlet 은 하나의 request 만 처리할 수 있지만, filter 는 chain 을 이루고 순서가 지정되며 실제로 request 자체를 처리할 때 filter 가 나머지 chain 이 처리 되지 않도록 할 수 있다. filter 는 이후에 적용될 filter 및 servlet 에 사용 될 request 와 response 를 수정할 수도 있다. 따라서 filter chain 의 순서는 매우 중요하다. Spring Boot 에서는 두 가지 메커니즘을 통해 filter chain 을 관리한다. Filter Type 의 @Beans 은 @Order 를 가지거나 Ordered 를 구현한다. one is that @Beans of type Filter can have an @Order or implement Ordered Filter 들이 API 의 일부로서 순서를 갖는 FilterRegistrationBean 의 일부가 될 수 있다. the other is that they can be part of a FilterRegistrationBean that itself has an order as part of its A...