首页 > 解决方案 > 如何在春季启动中的 OAuth2AuthenticationProcessingFilter 末尾添加自定义安全过滤器?

问题描述

我想在 oauth2authentication 处理过滤器之后添加自定义过滤器,用于进行一些自定义身份验证。我该怎么做?我的资源服务器类如下:

@EnableResourceServer
@EnableWebSecurity
@Configuration
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
        .authorizeRequests()
        .antMatchers("/").permitAll()
        
        .antMatchers("/agent/**").access("#oauth2.hasScope('Chatagent-message')")
        
        .anyRequest().authenticated()
        .and().csrf().disable();

    }
}

标签: springspring-bootspring-securityspring-oauth2

解决方案


推荐阅读