Unverified Commit 1d1afb6b authored by gaoyan's avatar gaoyan Committed by GitHub

Fix openapi token bug (#3136)

parent 11a20c2c
......@@ -34,6 +34,7 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import cn.dev33.satoken.exception.StopMatchException;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
/**
......@@ -74,14 +75,17 @@ public class AppConfig implements WebMvcConfigurer {
registry.addInterceptor(localeChangeInterceptor());
// 注册Sa-Token的路由拦截器
registry.addInterceptor(new SaInterceptor(handler -> {
boolean login = StpUtil.isLogin();
if (!login) {
SaRouter.match("/openapi/**", r -> {
if (!StpUtil.isLogin()) {
StpUtil.switchTo(BaseConstant.ADMIN_ID);
}
});
if (!StpUtil.isLogin()) {
throw new StopMatchException();
}
}))
.addPathPatterns("/api/**")
.excludePathPatterns(
"/api/login", "/api/ldap/ldapEnableStatus", "/download/**", "/druid/**", "/openapi/**");
.addPathPatterns("/api/**", "/openapi/**")
.excludePathPatterns("/api/login", "/api/ldap/ldapEnableStatus", "/download/**", "/druid/**");
registry.addInterceptor(new TenantInterceptor())
.addPathPatterns("/api/**")
......
......@@ -20,8 +20,6 @@
package org.dinky.controller;
import org.dinky.assertion.Asserts;
import org.dinky.data.annotations.Log;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.exception.BusException;
import org.dinky.data.model.FlinkUdfManifest;
import org.dinky.function.constant.PathConstant;
......@@ -61,7 +59,6 @@ import lombok.extern.slf4j.Slf4j;
public class DownloadController {
@GetMapping("downloadDepJar/{taskId}")
@Log(title = "Download UDF Jar", businessType = BusinessType.DOWNLOAD)
@ApiOperation("Download UDF Jar")
public void downloadJavaUDF(@PathVariable Integer taskId, HttpServletResponse resp) {
if (Asserts.isNull(taskId)) {
......@@ -108,7 +105,6 @@ public class DownloadController {
* @param resp resp
*/
@GetMapping("downloadAppJar/{version}")
@Log(title = "Download App Jar", businessType = BusinessType.DOWNLOAD)
@ApiOperation("Download App Jar")
public void downloadAppJar(@PathVariable String version, HttpServletResponse resp) {
List<File> files = FileUtil.loopFiles(
......@@ -119,7 +115,6 @@ public class DownloadController {
}
@GetMapping("downloadFromRs")
@Log(title = "Download From Resource", businessType = BusinessType.DOWNLOAD)
@ApiOperation("Download From Resource")
public void downloadJavaUDF(String path, HttpServletResponse resp) {
InputStream inputStream = BaseResourceManager.getInstance().readFile(path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment