2016-12-16 19 views
3

私はSpring Boot(1.4.2v)でswagger-uiでspringfox(2.6.1v)を使用します。spring-securityの背後にあるspringfox swagger-uiにアクセスする

そのための構成が見えます:

@Configuration 
@EnableSwagger2 
public class SwaggerConfig { 

    @Bean 
    public Docket api() { 
    return new Docket(DocumentationType.SWAGGER_2) 
       .select() 
       .apis(RequestHandlerSelectors.any()) 
       .paths(PathSelectors.any()) 
       .build() 
       .genericModelSubstitutes(ResponseEntity.class); 
    } 
} 

問題は、私の闊歩は春のセキュリティの背後にあるということであると私は管理者によってそこにアクセスを許可する必要があります。

質問アプリケーション内でswagger-uiを動作させるには、どのようなマッチャーが必要ですか?

public class SecurityConfig extends WebSecurityConfigurerAdapter { 

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
    http.authorizeRequests() 
     .antMatchers("??? <<<what_should_be_here>>> ???") // what should be here? 
     .hasRole("TENANT_ADMIN"); 
    } 
} 

答えて

1

[OK]を最初に私が見つけた解決策hereので、次の行:まだ

.antMatchers("/admin/system/state/*", "/v2/api-docs", "/configuration/ui", "/swagger-resources", "/configuration/security", "/swagger-ui.html", "/webjars/**") 

しかし、STHは動作しませんでしたし、そのため私はこの質問をしてきました。しかし、深い調査の後、それはバネの狐がGSONをサポートしていないことが起こった。 GSONを "to json"コンバータとして使用すると、swagger-uiは若干異なるJSON形式を受け取り、問題を引き起こします...

コンバータをジャンクションに変更し、上記のパスをspring-configに追加すると問題なく動作します。

私は春のキツネギブスの新機能をリクエストしましたhere

関連する問題