mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-05-08 04:51:26 +08:00
fix 修复 gateway设置默认请求头无法覆盖问题
This commit is contained in:
@@ -6,7 +6,10 @@ import cn.dev33.satoken.httpauth.basic.SaHttpBasicUtil;
|
|||||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||||
import cn.dev33.satoken.same.SaSameUtil;
|
import cn.dev33.satoken.same.SaSameUtil;
|
||||||
import cn.dev33.satoken.util.SaResult;
|
import cn.dev33.satoken.util.SaResult;
|
||||||
|
import cn.dev33.satoken.util.SaTokenConsts;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.dromara.common.core.constant.HttpStatus;
|
import org.dromara.common.core.constant.HttpStatus;
|
||||||
|
import org.dromara.common.core.utils.ServletUtils;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -42,6 +45,9 @@ public class SecurityConfiguration implements WebMvcConfigurer {
|
|||||||
if (SaManager.getConfig().getCheckSameToken()) {
|
if (SaManager.getConfig().getCheckSameToken()) {
|
||||||
SaSameUtil.checkCurrentRequestToken();
|
SaSameUtil.checkCurrentRequestToken();
|
||||||
}
|
}
|
||||||
|
// 对响应体设置默认头 后续代码可以覆盖
|
||||||
|
HttpServletResponse response = ServletUtils.getResponse();
|
||||||
|
response.setContentType(SaTokenConsts.CONTENT_TYPE_APPLICATION_JSON);
|
||||||
})
|
})
|
||||||
.setError(e -> SaResult.error("认证失败,无法访问系统资源").setCode(HttpStatus.UNAUTHORIZED));
|
.setError(e -> SaResult.error("认证失败,无法访问系统资源").setCode(HttpStatus.UNAUTHORIZED));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ public class AuthFilter implements WebMvcConfigurer {
|
|||||||
.notMatch(ignoreWhite.getWhites())
|
.notMatch(ignoreWhite.getWhites())
|
||||||
.check(() -> {
|
.check(() -> {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
HttpServletResponse response = ServletUtils.getResponse();
|
|
||||||
if (response != null) {
|
|
||||||
response.setContentType(SaTokenConsts.CONTENT_TYPE_APPLICATION_JSON);
|
|
||||||
}
|
|
||||||
|
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user