ソースを参照

Merge branch 'develop' of gitadmin/tuoheng_gateway into release

pull/33/head
gitadmin 1年前
コミット
2256042484
9個のファイルの変更160行の追加6行の削除
  1. +1
    -1
      src/main/java/com/tuoheng/gateway/config/GatewayFilterConfig.java
  2. +4
    -1
      src/main/java/com/tuoheng/gateway/config/WebSecurityConfig.java
  3. +1
    -1
      src/main/java/com/tuoheng/gateway/constants/AuthorityConstant.java
  4. +34
    -0
      src/main/java/com/tuoheng/gateway/constants/PermitPathConstant.java
  5. +6
    -1
      src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java
  6. +29
    -1
      src/main/resources/application-dev.yml
  7. +28
    -0
      src/main/resources/application-local.yml
  8. +28
    -0
      src/main/resources/application-prod.yml
  9. +29
    -1
      src/main/resources/application-test.yml

+ 1
- 1
src/main/java/com/tuoheng/gateway/config/GatewayFilterConfig.java ファイルの表示

//去除gateway path 前缀 //去除gateway path 前缀
String apiUrl = requestUrl.replace(GatewayUrlPathUtil.getPathByClientId(clientId),""); String apiUrl = requestUrl.replace(GatewayUrlPathUtil.getPathByClientId(clientId),"");
List<Integer> roleIds = GatewayUrlPathUtil.getRoleIdByApiUrlPermission(clientId, apiUrl, token); List<Integer> roleIds = GatewayUrlPathUtil.getRoleIdByApiUrlPermission(clientId, apiUrl, token);
log.info("roleIds is :{}", clientId);
log.info("roleIds is :{}", roleIds);
//return invalidClientIdMono(exchange); //return invalidClientIdMono(exchange);
if(roleIds.size() > 0){ if(roleIds.size() > 0){
//说明这个url 需要一定的角色才可以访问 //说明这个url 需要一定的角色才可以访问

+ 4
- 1
src/main/java/com/tuoheng/gateway/config/WebSecurityConfig.java ファイルの表示

package com.tuoheng.gateway.config; package com.tuoheng.gateway.config;


import com.tuoheng.gateway.constants.AuthorityConstant; import com.tuoheng.gateway.constants.AuthorityConstant;
import com.tuoheng.gateway.constants.PermitPathConstant;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerProperties; import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerProperties;
@Bean @Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity httpSecurity){ public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity httpSecurity){
String[] OAUTH_PATH = oauthUrlStr.split(","); String[] OAUTH_PATH = oauthUrlStr.split(",");
String[] PERMIT_PATH = permitUrlStr.split(",");
String[] HhzPermitPath = PermitPathConstant.hhzPermitUrlStr;
httpSecurity httpSecurity
.authorizeExchange() .authorizeExchange()
.pathMatchers(OAUTH_PATH).hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_DSP_MP, AuthorityConstant.SCOPE_TUOHNEG_DSP_WEB) .pathMatchers(OAUTH_PATH).hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_DSP_MP, AuthorityConstant.SCOPE_TUOHNEG_DSP_WEB)
.pathMatchers(HhzPermitPath).permitAll()
.pathMatchers("/pilot/miniprogram/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_PILOT_MP) .pathMatchers("/pilot/miniprogram/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_PILOT_MP)
.pathMatchers("/pilot/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_PILOT_ADMIN) .pathMatchers("/pilot/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_PILOT_ADMIN)
.pathMatchers("/hhz/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_HHZ_ADMIN) .pathMatchers("/hhz/admin/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_HHZ_ADMIN)
.pathMatchers("/hhz/api/**").hasAnyAuthority(AuthorityConstant.SCOPE_ADMIN, AuthorityConstant.SCOPE_TUOHNEG_HHZ_MP)
.pathMatchers("/oidc/admin/**").authenticated() .pathMatchers("/oidc/admin/**").authenticated()
//.pathMatchers(PERMIT_PATH).permitAll() //.pathMatchers(PERMIT_PATH).permitAll()
.anyExchange().permitAll() .anyExchange().permitAll()

+ 1
- 1
src/main/java/com/tuoheng/gateway/constants/AuthorityConstant.java ファイルの表示

*/ */
public static final String SCOPE_TUOHNEG_HHZ_ADMIN = "SCOPE_tuoheng-hhz-admin"; public static final String SCOPE_TUOHNEG_HHZ_ADMIN = "SCOPE_tuoheng-hhz-admin";


public static final String SCOPE_TUOHNEG_HHZ_MP = "SCOPE_tuoheng-hhz-mp";


} }

+ 34
- 0
src/main/java/com/tuoheng/gateway/constants/PermitPathConstant.java ファイルの表示

package com.tuoheng.gateway.constants;

/**
* @author chenjiandong
* @description: TODO
* @date 2022/12/1 8:49
*/
public class PermitPathConstant {

public static String hhzPermitUrlStr[] = {
"/hhz/admin/analyse/**",
"/hhz/admin/websocket/**",
"/hhz/admin/login/**",
"/hhz/admin/meeting/updatePeopleStatus/**",
"/hhz/admin/download/workUserExcel/**",
"/hhz/admin/tencentCloudRtc/genUserSig/**",
"/hhz/admin/inspection/track/**",
"/hhz/admin/inspection/uploadFlightUrl/**",
"/hhz/admin/inspection/updateTaskByCode/**",
"/hhz/admin/inspection/status/**",
"/hhz/admin/taskFile/**",
"/hhz/admin/flightdata/**",
"/hhz/admin/tenant/**",
"/hhz/admin/dsp/**",
"/hhz/admin/common/**",
"/hhz/api/tenant/**",
"/hhz/api/dsp/**",
"/hhz/api/meeting/updatePeopleStatus/**",
"/hhz/api/common/**",
"/hhz/api/common/**",
"/hhz/api/apiConfig/getConfigInfo/**"
};

}

+ 6
- 1
src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java ファイルの表示



private static final String HHZ_ADMIN = "tuoheng-hhz-admin"; private static final String HHZ_ADMIN = "tuoheng-hhz-admin";


private static final String HHZ_MP = "tuoheng-hhz-mp";

/** /**
* 获取 gateway 路由前缀,匹配url * 获取 gateway 路由前缀,匹配url
* @param clientId * @param clientId
case HHZ_ADMIN: case HHZ_ADMIN:
apiPath = "/hhz/admin"; apiPath = "/hhz/admin";
break; break;
case HHZ_MP:
apiPath = "/hhz/api";
break;
} }
return apiPath; return apiPath;
} }
*/ */
public static List<Integer> getRoleIdByApiUrlPermission(String clientId, String apiUrl, String token){ public static List<Integer> getRoleIdByApiUrlPermission(String clientId, String apiUrl, String token){
List<Integer> resList = new ArrayList<>(); List<Integer> resList = new ArrayList<>();
if(clientId.equals(HHZ_ADMIN)){
if(clientId.equals(HHZ_ADMIN) || clientId.equals(HHZ_MP)){
String url = CommonsConfig.hhzPermissionUrl; String url = CommonsConfig.hhzPermissionUrl;
HttpHeaders resultRequestHeader = new HttpHeaders(); HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + token); resultRequestHeader.add("Authorization", "Bearer " + token);

+ 29
- 1
src/main/resources/application-dev.yml ファイルの表示

- Path=/pilot/web/** - Path=/pilot/web/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# freeway后台管理
- id: tuoheng-freeway-admin
uri: lb://tuoheng-freeway-admin
predicates:
- Path=/freeway/admin/**
filters:
- StripPrefix=2
# freeway小程序服务
- id: tuoheng-freeway-miniprogram
uri: lb://tuoheng-freeway-miniprogram
predicates:
- Path=/freeway/miniprogram/**
filters:
- StripPrefix=2
# freeway api服务
- id: tuoheng-freeway-api
uri: lb://tuoheng-freeway-api
predicates:
- Path=/freeway/web/**
filters:
- StripPrefix=2
# oidc admin服务 # oidc admin服务
- id: tuoheng-oidc-admin - id: tuoheng-oidc-admin
uri: lb://tuoheng-oidc-admin uri: lb://tuoheng-oidc-admin
- Path=/hhz/admin/** - Path=/hhz/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# hhz 小程序服务
- id: tuoheng-hhz-api
uri: lb://tuoheng-hhz-api
predicates:
- Path=/hhz/api/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0


# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: tuoheng:
hhz-admin-perUrl: http://192.168.11.22:9055/api/permission/getRoleIdList
hhz-admin-perUrl: http://192.168.11.11:9055/permission/getRoleIdList

+ 28
- 0
src/main/resources/application-local.yml ファイルの表示

- Path=/pilot/web/** - Path=/pilot/web/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# freeway后台管理
- id: tuoheng-freeway-admin
uri: lb://tuoheng-freeway-admin
predicates:
- Path=/freeway/admin/**
filters:
- StripPrefix=2
# freeway小程序服务
- id: tuoheng-freeway-miniprogram
uri: lb://tuoheng-freeway-miniprogram
predicates:
- Path=/freeway/miniprogram/**
filters:
- StripPrefix=2
# freeway api服务
- id: tuoheng-freeway-api
uri: lb://tuoheng-freeway-api
predicates:
- Path=/freeway/web/**
filters:
- StripPrefix=2
# oidc admin服务 # oidc admin服务
- id: tuoheng-oidc-admin - id: tuoheng-oidc-admin
uri: lb://tuoheng-oidc-admin uri: lb://tuoheng-oidc-admin
- Path=/hhz/admin/** - Path=/hhz/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# hhz 小程序服务
- id: tuoheng-hhz-api
uri: lb://tuoheng-hhz-api
predicates:
- Path=/hhz/api/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0

+ 28
- 0
src/main/resources/application-prod.yml ファイルの表示

- Path=/pilot/web/** - Path=/pilot/web/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# freeway后台管理
- id: tuoheng-freeway-admin
uri: lb://tuoheng-freeway-admin
predicates:
- Path=/freeway/admin/**
filters:
- StripPrefix=2
# freeway小程序服务
- id: tuoheng-freeway-miniprogram
uri: lb://tuoheng-freeway-miniprogram
predicates:
- Path=/freeway/miniprogram/**
filters:
- StripPrefix=2
# freeway api服务
- id: tuoheng-freeway-api
uri: lb://tuoheng-freeway-api
predicates:
- Path=/freeway/web/**
filters:
- StripPrefix=2
# oidc admin服务 # oidc admin服务
- id: tuoheng-oidc-admin - id: tuoheng-oidc-admin
uri: lb://tuoheng-oidc-admin uri: lb://tuoheng-oidc-admin
- Path=/hhz/admin/** - Path=/hhz/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# hhz 小程序服务
- id: tuoheng-hhz-api
uri: lb://tuoheng-hhz-api
predicates:
- Path=/hhz/api/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0

+ 29
- 1
src/main/resources/application-test.yml ファイルの表示

- Path=/pilot/web/** - Path=/pilot/web/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# freeway后台管理
- id: tuoheng-freeway-admin
uri: lb://tuoheng-freeway-admin
predicates:
- Path=/freeway/admin/**
filters:
- StripPrefix=2
# freeway小程序服务
- id: tuoheng-freeway-miniprogram
uri: lb://tuoheng-freeway-miniprogram
predicates:
- Path=/freeway/miniprogram/**
filters:
- StripPrefix=2
# freeway api服务
- id: tuoheng-freeway-api
uri: lb://tuoheng-freeway-api
predicates:
- Path=/freeway/web/**
filters:
- StripPrefix=2
# oidc admin服务 # oidc admin服务
- id: tuoheng-oidc-admin - id: tuoheng-oidc-admin
uri: lb://tuoheng-oidc-admin uri: lb://tuoheng-oidc-admin
- Path=/hhz/admin/** - Path=/hhz/admin/**
filters: filters:
- StripPrefix=2 - StripPrefix=2
# hhz 小程序服务
- id: tuoheng-hhz-api
uri: lb://tuoheng-hhz-api
predicates:
- Path=/hhz/api/**
filters:
- StripPrefix=2
# Redis数据源 # Redis数据源
redis: redis:
# 缓存库默认索引0 # 缓存库默认索引0


# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: tuoheng:
hhz-admin-perUrl: http://192.168.11.22:9055/api/permission/getRoleIdList
hhz-admin-perUrl: http://172.15.1.21:9055/permission/getRoleIdList

読み込み中…
キャンセル
保存