spring-security 在何处创建名为springSecurityFilterChain的FilterChainProxy Bean?

g6ll5ycj  于 2022-11-11  发布在  Spring
关注(0)|答案(1)|浏览(144)

我正在使用Spring Security框架,我需要问一个问题。下面是我使用DelegatingFilterProxy调用FilterChainProxy的配置。

<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>/*</url-pattern> 
    </filter-mapping>
</filter>

据我所知,DelegatingFilterProxy通过指定它的名称来调用Filter接口实现。那么,在哪里(在代码中)以及何时创建了名为“springSecurityFilterChain”的FilterChainProxy bean呢?谢谢。

zpf6vheq

zpf6vheq1#

只需添加一个类以确保安全

package com.packageName.security;

@Configuration
@EnableWebSecurity
public class BlogAppSecurityConfig{

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
    .csrf().disable()
    .authorizeRequests().antMatchers("/").permitAll()
    .anyRequest().authenticated()
    .and()
    .httpBasic();
return http.build();
}

}

相关问题