优化
This commit is contained in:
@@ -40,6 +40,8 @@ public class GatewaySecurityConfig {
|
||||
properties.permitPaths().forEach(path -> exchanges.pathMatchers(path).permitAll());
|
||||
exchanges.pathMatchers("/api/merchant/**")
|
||||
.access(new AppScopeAuthorizationManager("MERCHANT"));
|
||||
exchanges.pathMatchers("/api/client/**")
|
||||
.access(new AppScopeAuthorizationManager("MERCHANT"));
|
||||
exchanges.pathMatchers("/api/platform/**")
|
||||
.access(new AppScopeAuthorizationManager("PLATFORM"));
|
||||
exchanges.anyExchange().authenticated();
|
||||
|
||||
@@ -78,6 +78,10 @@ spring:
|
||||
uri: lb://firstleg-service
|
||||
predicates:
|
||||
- Path=/api/merchant/v1/first-leg/**,/api/merchant/v1/customs/**,/api/platform/v1/first-leg/**,/api/platform/v1/customs/**,/api/platform/v1/port-schedules/**,/api/platform/v1/carrier-schedule-queries/**,/api/platform/v1/containers/**,/api/platform/v1/ocean-bookings/**,/api/platform/v1/truck-appointments/**,/api/platform/v1/fba-pricing/**,/api/platform/v1/inbounds/**,/api/platform/v1/fee-items/**,/api/platform/inbounds/**,/openapi/v1/inbound-measurements/**
|
||||
- id: finance-service
|
||||
uri: lb://finance-service
|
||||
predicates:
|
||||
- Path=/api/platform/finance/v1/**,/api/client/finance/v1/**
|
||||
# Swagger 文档聚合路由。
|
||||
- id: auth-openapi
|
||||
uri: lb://auth-service
|
||||
@@ -139,6 +143,12 @@ spring:
|
||||
- Path=/event-bridge-service/v3/api-docs/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: finance-openapi
|
||||
uri: lb://finance-service
|
||||
predicates:
|
||||
- Path=/finance-service/v3/api-docs/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
baiyue:
|
||||
cors:
|
||||
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,http://localhost:5174,http://127.0.0.1:5173,http://127.0.0.1:5174}
|
||||
@@ -170,6 +180,7 @@ baiyue:
|
||||
- /audit-service/v3/api-docs/**
|
||||
- /integration-service/v3/api-docs/**
|
||||
- /event-bridge-service/v3/api-docs/**
|
||||
- /finance-service/v3/api-docs/**
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
@@ -216,6 +227,8 @@ springdoc:
|
||||
url: /integration-service/v3/api-docs
|
||||
- name: event-bridge
|
||||
url: /event-bridge-service/v3/api-docs
|
||||
- name: finance
|
||||
url: /finance-service/v3/api-docs
|
||||
|
||||
logging:
|
||||
file:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.baiyue.gateway.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class FinanceRouteContractTest {
|
||||
@Test
|
||||
void routesOnlyTheConfirmedFinanceApiPrefixes() throws Exception {
|
||||
String yaml = new ClassPathResource("application.yml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(yaml)
|
||||
.contains("uri: lb://finance-service")
|
||||
.contains("/api/platform/finance/v1/**")
|
||||
.contains("/api/client/finance/v1/**")
|
||||
.doesNotContain("/api/platform/v1/finance")
|
||||
.doesNotContain("/api/merchant/v1/finance");
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesFinanceSwaggerAggregationRoute() throws Exception {
|
||||
String yaml = new ClassPathResource("application.yml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(yaml)
|
||||
.contains("/finance-service/v3/api-docs/**")
|
||||
.contains("url: /finance-service/v3/api-docs");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user