|
|
@ -24,6 +24,8 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties;
|
|
|
|
import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 网关鉴权
|
|
|
|
* 网关鉴权
|
|
|
@ -68,7 +70,7 @@ public class AuthFilter implements GlobalFilter, Ordered
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject obj = JSONObject.parseObject(userStr);
|
|
|
|
JSONObject obj = JSONObject.parseObject(userStr);
|
|
|
|
String userid = obj.getString("userid");
|
|
|
|
String userid = obj.getString("userid");
|
|
|
|
String username = obj.getString("username");
|
|
|
|
String username = urlEncode(obj.getString("username"));
|
|
|
|
if (StringUtils.isBlank(userid) || StringUtils.isBlank(username))
|
|
|
|
if (StringUtils.isBlank(userid) || StringUtils.isBlank(username))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return setUnauthorizedResponse(exchange, "令牌验证失败");
|
|
|
|
return setUnauthorizedResponse(exchange, "令牌验证失败");
|
|
|
@ -103,6 +105,18 @@ public class AuthFilter implements GlobalFilter, Ordered
|
|
|
|
return CacheConstants.LOGIN_TOKEN_KEY + token;
|
|
|
|
return CacheConstants.LOGIN_TOKEN_KEY + token;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 编码
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String urlEncode(String value) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
value = URLEncoder.encode(value, "UTF-8");
|
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取请求token
|
|
|
|
* 获取请求token
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|