Browse Source

新增设备管理系统的相关网关配置

pull/146/head
xiaoying 11 months ago
parent
commit
7c719d1452
6 changed files with 41 additions and 3 deletions
  1. +8
    -1
      src/main/java/com/tuoheng/gateway/commons/CommonsConfig.java
  2. +1
    -0
      src/main/java/com/tuoheng/gateway/config/WebSecurityConfig.java
  3. +6
    -0
      src/main/java/com/tuoheng/gateway/constants/AuthorityConstant.java
  4. +8
    -0
      src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java
  5. +9
    -1
      src/main/resources/application-dev.yml
  6. +9
    -1
      src/main/resources/application-test.yml

+ 8
- 1
src/main/java/com/tuoheng/gateway/commons/CommonsConfig.java View File

* 数字孪生服务接口地址 * 数字孪生服务接口地址
*/ */
public static String digitaltwinPermissionUrl; public static String digitaltwinPermissionUrl;
/**
* 设备管理服务接口地址
*/
public static String dmpPermissionUrl;




@Value("${tuoheng.hhz-admin-perUrl}") @Value("${tuoheng.hhz-admin-perUrl}")
public void setHhzPermissionUrl(String url) { public void setHhzPermissionUrl(String url) {
hhzPermissionUrl = url; hhzPermissionUrl = url;
} }

@Value("${tuoheng.dmp-admin-perUrl}")
public void setDmpPermissionUrl(String url) {
dmpPermissionUrl = url;
}
@Value("${tuoheng.spacetime-admin-perUrl}") @Value("${tuoheng.spacetime-admin-perUrl}")
public void setSpacetimePermissionUrl(String url) { public void setSpacetimePermissionUrl(String url) {
spacetimePermissionUrl = url; spacetimePermissionUrl = url;

+ 1
- 0
src/main/java/com/tuoheng/gateway/config/WebSecurityConfig.java View File

.pathMatchers("/alert/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_ALERT_ADMIN) .pathMatchers("/alert/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_ALERT_ADMIN)
.pathMatchers("/spacetime/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_SPACETIME_ADMIN) .pathMatchers("/spacetime/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_SPACETIME_ADMIN)
.pathMatchers("/digitaltwin/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_DIGITALTWIN_ADMIN) .pathMatchers("/digitaltwin/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_DIGITALTWIN_ADMIN)
.pathMatchers("/dmp/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_DMP_ADMIN)
.pathMatchers("/airport/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_AIRPORT_ADMIN) .pathMatchers("/airport/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_AIRPORT_ADMIN)
.pathMatchers("/oidc/admin/user/**").authenticated() .pathMatchers("/oidc/admin/user/**").authenticated()
.pathMatchers("/api/inspection/**").authenticated() .pathMatchers("/api/inspection/**").authenticated()

+ 6
- 0
src/main/java/com/tuoheng/gateway/constants/AuthorityConstant.java View File

*/ */
public static final String SCOPE_TUOHNEG_DIGITALTWIN_ADMIN = "SCOPE_tuoheng-digitaltwin-admin"; public static final String SCOPE_TUOHNEG_DIGITALTWIN_ADMIN = "SCOPE_tuoheng-digitaltwin-admin";
//public static final String SCOPE_TUOHNEG_ALERT_MP= "SCOPE_tuoheng-alert-mp"; //public static final String SCOPE_TUOHNEG_ALERT_MP= "SCOPE_tuoheng-alert-mp";

/**
* Digitaltwin 用户权限
*/
public static final String SCOPE_TUOHNEG_DMP_ADMIN = "SCOPE_tuoheng-dmp-admin";
//public static final String SCOPE_TUOHNEG_DMP_MP= "SCOPE_tuoheng-dmp-mp";
} }

+ 8
- 0
src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java View File



private static final String DIGITALTWIN_ADMIN = "tuoheng-digitaltwin-admin"; private static final String DIGITALTWIN_ADMIN = "tuoheng-digitaltwin-admin";


private static final String DMP_ADMIN = "tuoheng-dmp-admin";



/** /**
* 获取 gateway 路由前缀,匹配url * 获取 gateway 路由前缀,匹配url
case DIGITALTWIN_ADMIN: case DIGITALTWIN_ADMIN:
apiPath = "/digitaltwin/admin"; apiPath = "/digitaltwin/admin";
break; break;
case DMP_ADMIN:
apiPath = "/dmp/admin";
break;
default: default:
break; break;
} }
if (clientId.equals(DIGITALTWIN_ADMIN)) { if (clientId.equals(DIGITALTWIN_ADMIN)) {
url = CommonsConfig.digitaltwinPermissionUrl; url = CommonsConfig.digitaltwinPermissionUrl;
} }
if (clientId.equals(DMP_ADMIN)) {
url = CommonsConfig.dmpPermissionUrl;
}
log.info("getRoleIdByApiUrlPermission -url:{},token:{}", url, token); log.info("getRoleIdByApiUrlPermission -url:{},token:{}", url, token);
if (StringUtils.isNotBlank(url)) { if (StringUtils.isNotBlank(url)) {
HttpHeaders resultRequestHeader = new HttpHeaders(); HttpHeaders resultRequestHeader = new HttpHeaders();

+ 9
- 1
src/main/resources/application-dev.yml View File

- Path=/digitaltwin/admin/** - Path=/digitaltwin/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# 设备管理 admin服务
- id: tuoheng-digitaltwin-admin
uri: lb://tuoheng-digitaltwin-admin
predicates:
- Path=/digitaltwin/admin/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0
airmonitor-admin-perUrl: http://192.168.11.11:9130/permission/getRoleIdList airmonitor-admin-perUrl: http://192.168.11.11:9130/permission/getRoleIdList
telecomumale-admin-perUrl: http://192.168.11.11:9150/permission/getRoleIdList telecomumale-admin-perUrl: http://192.168.11.11:9150/permission/getRoleIdList
spacetime-admin-perUrl: http://192.168.11.11:9170/permission/getRoleIdList spacetime-admin-perUrl: http://192.168.11.11:9170/permission/getRoleIdList
digitaltwin-admin-perUrl: http://192.168.11.11:9180/permission/getRoleIdList
digitaltwin-admin-perUrl: http://192.168.11.11:9180/permission/getRoleIdList
dmp-admin-perUrl: http://192.168.11.11:9190/permission/getRoleIdList

+ 9
- 1
src/main/resources/application-test.yml View File

- Path=/digitaltwin/admin/** - Path=/digitaltwin/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# 设备管理 admin服务
- id: tuoheng-digitaltwin-admin
uri: lb://tuoheng-digitaltwin-admin
predicates:
- Path=/digitaltwin/admin/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0
airmonitor-admin-perUrl: https://airmonitor-test.t-aaron.com/permission/getRoleIdList airmonitor-admin-perUrl: https://airmonitor-test.t-aaron.com/permission/getRoleIdList
telecomumale-admin-perUrl: https://telecomumale-test.t-aaron.com/permission/getRoleIdList telecomumale-admin-perUrl: https://telecomumale-test.t-aaron.com/permission/getRoleIdList
spacetime-admin-perUrl: https://spacetime-test.t-aaron.com/permission/getRoleIdList spacetime-admin-perUrl: https://spacetime-test.t-aaron.com/permission/getRoleIdList
digitaltwin-admin-perUrl: https://digitaltwin-test.t-aaron.com/permission/getRoleIdList
digitaltwin-admin-perUrl: https://digitaltwin-test.t-aaron.com/permission/getRoleIdList
dmp-admin-perUrl: https://dmp-test.t-aaron.com/permission/getRoleIdList

Loading…
Cancel
Save