graphiQL支持spring安全吗?添加Spring安全性后graphiQL UI无法正常工作

时间:2019-09-11 07:02:00

标签: spring spring-boot graphql spring-security-oauth2 graphiql

JS CSS files are not loading

我尝试了下面的代码来允许js和CSS文件

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/v2/api-docs",
                               "/configuration/ui",
                               "/swagger-resources/**",
                               "/configuration/security",
                               "/swagger-ui.html",
                               "/webjars/**",
                               "/graphiql",
                               "/resources/**"
                                );
}



  /*@Override
  public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/resources/**"); // #3
  }*/

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
        .antMatchers("/resources/**").permitAll()
        .antMatchers("/*.js").permitAll()
        .antMatchers("/*.css").permitAll()
        .antMatchers("/*.html").permitAll()
        .and().csrf().disable();
  } 

我觉得Graphiql UI有问题吗? 谁能帮忙吗?

供参考GraphiQL UI进行查询 GraphiQL UI

1 个答案:

答案 0 :(得分:1)

我使用了下一个匹配器来渲染graphiQl

.antMatchers("/graphiql", "/vendor/**").permitAll()

GraphiQL版本为5.0.2