스터디-Spring

[스프링 시큐리티] Filter와 FilterChainProxy

일태우 2022. 1. 12. 23:05
반응형

FilterChainProxy는 SecurityFilterChain 인스턴스로 구성되어 있는 리스트를(filterChains) 사용하며, 각 인스턴스에는 RequestMatcher와 일치하는 요청에 적용해야하는 필터 목록이 포함되어 있다

FilterChainProxy.getFilters 메서드
FormLogin, BasicLogin 설정시 아래와 같다.

  1. WebAsyncManagerIntergrationFilter
  2. SecurityContextPersistenceFilter
  3. HeaderWriterFilter
  4. CsrfFilter
  5. LogoutFilter
  6. UsernamePasswordAuthenticationFilter(formlogin)
  7. DefaultLoginPageGeneratingFilter(formlogin)
  8. DefaultLogoutPageGeneratingFilter(formlogin)
  9. BasicAuthenticationFilter(basiclogin)
  10. RequestCacheAwareFtiler
  11. SecurityContextHolderAwareReqeustFilter
  12. AnonymouseAuthenticationFilter
  13. SessionManagementFilter
  14. ExeptionTranslationFilter
  15. FilterSecurityInterceptor
protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .mvcMatchers("/", "/info", "/account/**").permitAll()
                .mvcMatchers("/admin").hasRole("ADMIN")
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .and()
            .httpBasic();
    }

위와 같이 설정한 부분이 filterChains로 적용된다.

반응형