2016-04-29 95 views
5

我已經爲我的應用程序中列出的所有控制器設置並使用了Swagger。但是,我希望它能夠獲得Spring Security Logout端點,並且找不到一種方法來實現它。正如你從下面的代碼片段可以看到的,我爲用戶指定了一個logoutUrl來使其會話無效。我已經嘗試了課程級別的註釋標記和方法級別,但沒有運氣。有任何想法嗎?配置Swagger-UI來獲取Spring的HttpSecurity註銷端點

@Override 
public void configure(HttpSecurity http) throws Exception { 
    http.addFilter(someFilter()); 
    http.headers().and().csrf().disable() 
      .authorizeRequests() 
      .antMatchers("endpoint", 
        "endpoint", 
        "endpoint", 
        "endpoint", 
        "endpoint", 
        "endpoint", 
        "endpoint").permitAll()  
      .anyRequest().authenticated() 
      .and() 
      .logout().logoutUrl("endpoint/logout").invalidateHttpSession(true).logoutSuccessHandler(logoutSuccessHandler); 
} 

我揚鞭文案配置低於:

@Bean 
public Docket api() { 
    return new Docket(DocumentationType.SWAGGER_2) 
      .select() 
      .apis(RequestHandlerSelectors.any()) 
      .paths(PathSelectors.any()) 
      .build() 
      .apiInfo(new ApiInfo("API", 
        "Provides API's", 
        "1.0", 
        null, 
        "[email protected].com", 
        null, 
        null)) 
      .useDefaultResponseMessages(false) 
      .pathProvider(new RelativePathProvider(servletContext) { 
       @Override 
       protected String applicationPath() { 
        return super.applicationPath() + "/path"; 
       } 

       @Override 
       protected String getDocumentationPath() { 
        return super.getDocumentationPath() + "/path"; 
       } 
      }); 
} 

回答

相關問題