Skip to content

Commit

Permalink
update SwaggerConfig.java
Browse files Browse the repository at this point in the history
  • Loading branch information
elunez committed Jul 12, 2023
1 parent 6d4a004 commit 61c7131
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.description("一个简单且易上手的 Spring boot 后台管理框架")
.title("ELADMIN 接口文档")
.version("2.6")
.version("2.7")
.build();
}

Expand All @@ -93,16 +93,15 @@ private List<SecurityScheme> securitySchemes() {
private List<SecurityContext> securityContexts() {
//设置需要登录认证的路径
List<SecurityContext> securityContexts = new ArrayList<>();
// ^(?!auth).*$ 表示所有包含auth的接口不需要使用securitySchemes即不需要带token
// ^标识开始 ()里是一子表达式 ?!/auth表示匹配不是/auth的位置,匹配上则添加请求头,注意路径已/开头 .表示任意字符 *表示前面的字符匹配多次 $标识结束
securityContexts.add(getContextByPath());
return securityContexts;
}

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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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;
Expand Down Expand Up @@ -141,7 +140,7 @@ public ResponseEntity<Object> getCode() {
}

@ApiOperation("退出登录")
@AnonymousDeleteMapping(value = "/logout")
@DeleteMapping(value = "/logout")
public ResponseEntity<Object> logout(HttpServletRequest request) {
onlineUserService.logout(tokenProvider.getToken(request));
return new ResponseEntity<>(HttpStatus.OK);
Expand Down

0 comments on commit 61c7131

Please sign in to comment.