Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hphy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
向怀芳
hphy
Commits
934cb13c
Commit
934cb13c
authored
Sep 10, 2025
by
gaozhaochen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 生产环境无白名单配置时,全局过滤器白名单标志获取错误问题
parent
25684165
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
RequestGlobalFilter.java
...sict/cloud/common/gateway/filter/RequestGlobalFilter.java
+5
-3
No files found.
cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java
View file @
934cb13c
package
cn
.
sh
.
stc
.
sict
.
cloud
.
common
.
gateway
.
filter
;
import
cn.hutool.json.JSONUtil
;
import
cn.sh.stc.sict.cloud.common.core.constant.Constant
;
import
cn.sh.stc.sict.cloud.common.core.constant.SecurityConstants
;
import
cn.sh.stc.sict.cloud.common.core.util.R
;
...
...
@@ -62,12 +63,12 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
httpHeaders
.
remove
(
SecurityConstants
.
FROM
);
})
.
build
();
log
.
error
(
"这里没问题"
);
// IP白名单
String
ip
=
WebUtils
.
getIP
(
request
);
// log.error("RemoteAddress = {}, ip = {}", request.getRemoteAddress(), ip);
try
{
if
(
whitIPConfig
.
getLimitFlag
()
&&
!
IPStrUtil
.
matches
(
ip
,
whitIPConfig
.
getWhites
()))
{
if
(
whitIPConfig
.
getLimitFlag
()
!=
null
&&
whitIPConfig
.
getLimitFlag
()
&&
!
IPStrUtil
.
matches
(
ip
,
whitIPConfig
.
getWhites
()))
{
ServerHttpResponse
response
=
exchange
.
getResponse
();
response
.
setStatusCode
(
HttpStatus
.
PRECONDITION_REQUIRED
);
response
.
getHeaders
().
set
(
"Content-type"
,
"application/json; charset=utf-8"
);
...
...
@@ -90,6 +91,7 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
log
.
error
(
"对象输出异常"
,
e1
);
}
}
log
.
error
(
"这里没问题2"
);
// 2. 重写StripPrefix
addOriginalRequestUrl
(
exchange
,
request
.
getURI
());
String
rawPath
=
request
.
getURI
().
getRawPath
();
...
...
@@ -99,7 +101,7 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
.
path
(
newPath
)
.
build
();
exchange
.
getAttributes
().
put
(
GATEWAY_REQUEST_URL_ATTR
,
newRequest
.
getURI
());
log
.
error
(
"这里没问题3"
);
return
chain
.
filter
(
exchange
.
mutate
()
.
request
(
newRequest
.
mutate
()
.
build
()).
build
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment