From 480cfc542da32486cee6a01a2f811dca03e42d1c Mon Sep 17 00:00:00 2001
From: 刘帅 <rr.iii@qq.com>
Date: 星期日, 20 九月 2026 10:32:32 +0800
Subject: [PATCH] bug:手机号加密问题

---
 cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/SensitiveDataMaskingGlobalFilter.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/SensitiveDataMaskingGlobalFilter.java b/cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/SensitiveDataMaskingGlobalFilter.java
index d1dea58..b150ae6 100644
--- a/cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/SensitiveDataMaskingGlobalFilter.java
+++ b/cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/SensitiveDataMaskingGlobalFilter.java
@@ -21,6 +21,13 @@
 /** Final API boundary for APP traffic, including responses returned by every service. */
 @Component
 public class SensitiveDataMaskingGlobalFilter implements GlobalFilter, Ordered {
+    /**
+     * This response contains the current user's own phone number, which the APP
+     * needs in its original form.  The account service marks the field with
+     * {@code @UnmaskedSensitiveData}; the gateway works on JSON text, so it
+     * must mirror that narrow exception here.
+     */
+    private static final String UNMASKED_USER_DETAILS_PATH = "/account/api/useBenefit/userDetails";
     private static final Pattern FIELD = Pattern.compile("(?i)(\\\"(?:[a-z]*phone|[a-z]*mobile|telephone|tel)\\\"\\s*:\\s*\\\")([^\\\"]*)(\\\")");
     private static final Pattern IDCARD = Pattern.compile("(?i)(\\\"(?:[a-z]*idcard|[a-z]*identitycard|identitynumber|idnumber)\\\"\\s*:\\s*\\\")([^\\\"]*)(\\\")");
 
@@ -28,7 +35,8 @@
 
     @Override public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
         // This route itself enforces the admin check and writes an audit record.
-        if (exchange.getRequest().getURI().getPath().startsWith("/system/sensitive/")) return chain.filter(exchange);
+        String path = exchange.getRequest().getURI().getPath();
+        if (path.startsWith("/system/sensitive/") || UNMASKED_USER_DETAILS_PATH.equals(path)) return chain.filter(exchange);
         ServerHttpResponseDecorator decorated = new ServerHttpResponseDecorator(exchange.getResponse()) {
             @Override public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
                 MediaType type = getHeaders().getContentType();

--
Gitblit v1.7.1