update SwaggerConfig.java

close https://gitee.com/elunez/eladmin-mp/issues/I7K6A4
This commit is contained in:
Zheng Jie 2023-07-12 16:22:13 +08:00
parent a84d3157ab
commit 0bbbdcbefb
2 changed files with 4 additions and 6 deletions

View File

@ -67,7 +67,7 @@ public class SwaggerConfig {
return new ApiInfoBuilder()
.description("一个简单且易上手的 Spring boot 后台管理框架")
.title("ELADMIN 接口文档")
.version("2.6")
.version("1.0")
.build();
}
@ -82,8 +82,6 @@ public class SwaggerConfig {
private List<SecurityContext> securityContexts() {
//设置需要登录认证的路径
List<SecurityContext> securityContexts = new ArrayList<>();
// ^(?!auth).*$ 表示所有包含auth的接口不需要使用securitySchemes即不需要带token
// ^标识开始 ()里是一子表达式 ?!/auth表示匹配不是/auth的位置匹配上则添加请求头注意路径已/开头 .表示任意字符 *表示前面的字符匹配多次 $标识结束
securityContexts.add(getContextByPath());
return securityContexts;
}
@ -91,7 +89,8 @@ public class SwaggerConfig {
private SecurityContext getContextByPath() {
return SecurityContext.builder()
.securityReferences(defaultAuth())
.operationSelector(o->o.requestMappingPattern().matches("^(?!/auth).*$"))
// 表示 /auth/code/auth/login 接口不需要使用securitySchemes即不需要带token
.operationSelector(o->o.requestMappingPattern().matches("^(?!/auth/code|/auth/login).*$"))
.build();
}

View File

@ -22,7 +22,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.annotation.rest.AnonymousDeleteMapping;
import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.annotation.rest.AnonymousPostMapping;
import me.zhengjie.config.RsaProperties;
@ -141,7 +140,7 @@ public class AuthorizationController {
}
@ApiOperation("退出登录")
@AnonymousDeleteMapping(value = "/logout")
@DeleteMapping(value = "/logout")
public ResponseEntity<Object> logout(HttpServletRequest request) {
onlineUserService.logout(tokenProvider.getToken(request));
return new ResponseEntity<>(HttpStatus.OK);