@@ -14,13 +14,24 @@ import org.springframework.context.annotation.Configuration; | |||
public class CommonsConfig { | |||
/** | |||
* 图片域名 | |||
* 河湖长权限接口地址 | |||
*/ | |||
public static String hhzPermissionUrl; | |||
/** | |||
* 高速权限接口地址 | |||
*/ | |||
public static String freewayPermissionUrl; | |||
@Value("${tuoheng.hhz-admin-perUrl}") | |||
public void setPermissionUrl(String url) { | |||
hhzPermissionUrl = url; | |||
} | |||
@Value("${tuoheng.hhz-admin-perUrl}") | |||
public void setFreewayPermissionUrl(String url) { | |||
freewayPermissionUrl = url; | |||
} | |||
} |
@@ -59,13 +59,12 @@ public class GatewayFilterConfig implements GlobalFilter, Ordered { | |||
} | |||
//header里封装 Client-Id 信息 | |||
String clientId = getClientId(exchange); | |||
log.info("clientId is :{}", clientId); | |||
if(!StringUtils.isEmpty(clientId)){ | |||
log.info("clientId is :{}", clientId); | |||
String requestUrl = exchange.getRequest().getPath().value(); | |||
log.info("requestUrl is :{}", requestUrl); | |||
//去除gateway path 前缀 | |||
String apiUrl = requestUrl.replace(GatewayUrlPathUtil.getPathByClientId(clientId),""); | |||
log.info("apiUrl is :{}", apiUrl); | |||
log.info("requestUrl is :{}; apiUrl is :{}", requestUrl, apiUrl); | |||
List<Integer> roleIds = GatewayUrlPathUtil.getRoleIdByApiUrlPermission(clientId, apiUrl, token); | |||
log.info("roleIds is :{}", roleIds); | |||
//return invalidClientIdMono(exchange); |
@@ -65,8 +65,11 @@ public class GatewayUrlPathUtil { | |||
if(clientId.equals(HHZ_ADMIN) || clientId.equals(HHZ_MP)){ | |||
url = CommonsConfig.hhzPermissionUrl; | |||
} | |||
if(clientId.equals(FREEWAY_ADMIN) || clientId.equals(FREEWAY_MP)){ | |||
url = CommonsConfig.freewayPermissionUrl; | |||
} | |||
log.info("getRoleIdByApiUrlPermission - url:{}", url); | |||
if(StringUtils.isNotBlank(url)){ | |||
log.info("getRoleIdByApiUrlPermission - url:{}", url); | |||
HttpHeaders resultRequestHeader = new HttpHeaders(); | |||
resultRequestHeader.add("Authorization", "Bearer " + token); | |||
JSONObject json = new JSONObject(); |
@@ -193,4 +193,5 @@ security: | |||
# 获取 apiUrl 可访问的 roleIdList | |||
tuoheng: | |||
hhz-admin-perUrl: http://192.168.11.11:9055/permission/getRoleIdList | |||
hhz-admin-perUrl: http://192.168.11.11:9055/permission/getRoleIdList | |||
freeway-admin-perUrl: http://192.168.11.11:9117/permission/getRoleIdList |
@@ -192,4 +192,5 @@ security: | |||
# 获取 apiUrl 可访问的 roleIdList | |||
tuoheng: | |||
hhz-admin-perUrl: http://127.0.0.1:9055/api/permission/getRoleIdList | |||
hhz-admin-perUrl: http://127.0.0.1:9055/api/permission/getRoleIdList | |||
freeway-admin-perUrl: |
@@ -186,3 +186,4 @@ security: | |||
# 获取 apiUrl 可访问的 roleIdList | |||
tuoheng: | |||
hhz-admin-perUrl: https://hhz.t-aaron.com/permission/getRoleIdList | |||
freeway-admin-perUrl: |
@@ -186,4 +186,5 @@ security: | |||
# 获取 apiUrl 可访问的 roleIdList | |||
tuoheng: | |||
hhz-admin-perUrl: http://172.15.1.21:9055/permission/getRoleIdList | |||
hhz-admin-perUrl: http://172.15.1.21:9055/permission/getRoleIdList | |||
freeway-admin-perUrl: |