【发布时间】:2016-08-25 03:11:45
【问题描述】:
我已经为我的应用程序中列出的所有控制器设置并工作了 Swagger。但是,我希望它能够获取 Spring Security Logout Endpoint,但我找不到让它工作的方法。正如您从下面的代码 sn-p 中看到的那样,我正在为用户指定一个 logoutUrl 以使他们的会话无效。我已经尝试过类级别的注释标记和方法级别,但没有运气。有什么想法吗?
@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);
}
我的 Swagger Docket 配置如下:
@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,
"someEmail@nowhere.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";
}
});
}
【问题讨论】:
标签: java spring spring-mvc spring-security swagger-ui