找不到org.springframework.security.config.annotation.ObjectPostProcessor'

ffscu2ro  于 2023-10-20  发布在  Spring
关注(0)|答案(1)|浏览(165)

我刚刚使用lognet.grpc spring Boot starter实现了GRPC,在启动应用程序时出现了以下错误。

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your configuration.

下面是SpringSecuritySecurityClass

@Configuration
@EnableWebSecurity
@ImportResource({"classpath:spring-ADFS-security.xml"})
public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter {

  @Autowired
  private OAuthUserDetailsService userDetailsService;

  @Primary
  @Bean
  @Override
  public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
  }

  @Primary
  @Bean
  public PasswordEncoder encoder() {
    return new StandardPasswordEncoder();
  }

  @Autowired
  protected void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(encoder());
  }

  /**
   * @Order annotation is used to advise execution precedence. The highest precedence runs first.
   */
  @Override
  @Order(Ordered.HIGHEST_PRECEDENCE)
  protected void configure(HttpSecurity http) throws Exception {
    http.anonymous() //
        .disable() //
        .authorizeRequests() //
        .anyRequest() //
        .authenticated() //
        .and() //
        .httpBasic() //
        .and() //
        .sessionManagement() //
        .sessionCreationPolicy(SessionCreationPolicy.STATELESS) //
        .and() //
        .csrf() //
        .disable();
  }
}

这是使用adfs-security的主要配置文件。希望有帮助。

vd8tlhqk

vd8tlhqk1#

解决方案:
只需在application.properties中添加grpc.security.auth.enabled = false
根据文件:

  • 通过将grpc.security.auth.enabled设置为false,可以关闭GRPC安全性。
  • GRPC安全配置遵循与Spring WEB安全配置相同的主体和API,如果您在classpath中有www.example.com:spring-security-config依赖项,则org.springframework.security

相关问题