Commit 48c7badf authored by 向怀芳's avatar 向怀芳 🎱

1. IP白名单02

parent 0cf3fe3d
......@@ -61,8 +61,6 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
public GatewayFilter apply(Object config) {
return (exchange, chain) -> {
ServerHttpRequest request = exchange.getRequest();
// IP白名单
log.error("RemoteAddress ===================> {}", request.getRemoteAddress());
// 不是登录请求,直接向下执行
if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), SecurityConstants.OAUTH_TOKEN_URL)) {
......@@ -70,19 +68,19 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
}
URI uri = exchange.getRequest().getURI();
log.error("uri ==============>: {}", uri.toString());
// log.error("uri ==============>: {}", uri.toString());
String queryParam = uri.getRawQuery();
log.error("queryParam==============>: {}", queryParam);
// log.error("queryParam==============>: {}", queryParam);
Map<String, String> paramMap = HttpUtil.decodeParamMap(queryParam, CharsetUtil.UTF_8);
log.error("paramMap==============>: {}", paramMap.toString());
// log.error("paramMap==============>: {}", paramMap.toString());
String password = paramMap.get(PASSWORD);
if (StrUtil.isNotBlank(password)) {
try {
// password = decryptAES(password, encodeKey);
log.error("before password: {}", password);
// log.error("before password: {}", password);
password = CryptUtil.AESToString(password, encodeKey);
log.error("after password: {}", password);
// log.error("after password: {}", password);
} catch (Exception e) {
log.error("密码解密失败:password = {}", password);
return Mono.error(e);
......@@ -93,9 +91,9 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
if (StrUtil.isNotBlank(username)) {
try {
// password = decryptAES(password, encodeKey);
log.error("before username: {}", username);
// log.error("before username: {}", username);
username = CryptUtil.AESToString(username, encodeKey);
log.error("after username: {}", username);
// log.error("after username: {}", username);
} catch (Exception e) {
log.error("用户名解密失败:username = {}", username);
return Mono.error(e);
......
package cn.sh.stc.sict.cloud.common.gateway.filter;
import cn.sh.stc.sict.cloud.common.core.constant.SecurityConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
......@@ -28,6 +29,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.a
* @Author
* @Date
*/
@Slf4j
@Component
public class RequestGlobalFilter implements GlobalFilter, Ordered {
private static final String HEADER_NAME = "X-Forwarded-Prefix";
......@@ -47,6 +49,9 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
.headers(httpHeaders -> {httpHeaders.remove(SecurityConstants.FROM);})
.build();
// IP白名单
log.error("RemoteAddress ===================> {}", request.getRemoteAddress());
// 2. 重写StripPrefix
addOriginalRequestUrl(exchange, request.getURI());
String rawPath = request.getURI().getRawPath();
......
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