2020
2121/**
2222 * OmsAuthFilter is a global filter that authenticates requests to the OMS service.
23- *
23+ *
2424 * @author songyongtan
2525 * @date 2026-03-16
2626 */
@@ -38,7 +38,7 @@ public class OmsAuthFilter implements GlobalFilter {
3838
3939 /**
4040 * OmsAuthFilter constructor.
41- *
41+ *
4242 * @param omsAuthEnable whether OMS authentication is enabled
4343 * @param omsService OMS service client
4444 * @param omsExtensionService OMS extension service client
@@ -55,7 +55,7 @@ public OmsAuthFilter(
5555
5656 /**
5757 * filter processes the request and adds authentication headers.
58- *
58+ *
5959 * @param exchange the server web exchange
6060 * @param chain the gateway filter chain
6161 * @return Mono<Void> completion signal
@@ -97,33 +97,47 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
9797
9898 /**
9999 * getRealIp gets the real IP address from the request.
100- *
100+ *
101101 * @param request the HTTP request
102102 * @return the real IP address
103103 */
104104 private String getRealIp (ServerHttpRequest request ) {
105105 String ip = request .getHeaders ().getFirst ("X-Real-IP" );
106+ log .info ("==================================================================================================" );
107+ log .info ("request: {}" , request );
108+ log .info ("request params: {}" , request .getQueryParams ());
109+ log .info ("request headers: {}" , request .getHeaders ());
110+ log .info ("local address: {}, remote address: {}" , request .getLocalAddress (), request .getRemoteAddress ());
111+ log .info ("cookies:{}" , request .getCookies ());
112+ log .info ("attributes:{}" , request .getAttributes ());
113+ log .info ("URI:{}" , request .getURI ());
106114 if (ip == null || ip .isEmpty () || "unknown" .equalsIgnoreCase (ip )) {
107115 ip = request .getHeaders ().getFirst ("X-Forwarded-For" );
108116 }
117+ log .info ("1 ip: {}" , ip );
109118 if (ip == null || ip .isEmpty () || "unknown" .equalsIgnoreCase (ip )) {
110119 ip = request .getHeaders ().getFirst ("Proxy-Client-IP" );
111120 }
121+ log .info ("2 ip: {}" , ip );
112122 if (ip == null || ip .isEmpty () || "unknown" .equalsIgnoreCase (ip )) {
113123 ip = request .getHeaders ().getFirst ("WL-Proxy-Client-IP" );
114124 }
125+ log .info ("3 ip: {}" , ip );
115126 if (ip == null || ip .isEmpty () || "unknown" .equalsIgnoreCase (ip )) {
116127 ip = request .getRemoteAddress () != null ? request .getRemoteAddress ().getAddress ().getHostAddress () : "" ;
117128 }
129+ log .info ("4 ip: {}" , ip );
118130 if (ip != null && ip .contains ("," )) {
119131 ip = ip .split ("," )[0 ].trim ();
120132 }
133+ log .info ("5 ip: {}" , ip );
134+ log .info ("==================================================================================================" );
121135 return ip != null ? ip : "" ;
122136 }
123137
124138 /**
125139 * getToken gets the token value from cookies.
126- *
140+ *
127141 * @param cookies the cookies map
128142 * @param tokenKey the token key
129143 * @return the token value
0 commit comments