功能:新增下一阶段运营能力和生产部署
This commit is contained in:
+7
@@ -98,10 +98,14 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
"/api/user/reset-password-by-phone",
|
||||
"/api/legal-agreement/current",
|
||||
"/api/legal-agreement/current/**",
|
||||
"/api/nail-artist/profile/**",
|
||||
"/api/nail-artist/*/availability",
|
||||
"/api/nail-artist/*/reviews",
|
||||
"/api/product/get/**",
|
||||
"/api/product/list/**",
|
||||
"/api/comment/list/product/**",
|
||||
"/api/shop/get/**",
|
||||
"/api/shop/list",
|
||||
"/api/shop/list/public",
|
||||
"/api/shop/list/simple",
|
||||
"/api/tag/list/all",
|
||||
@@ -110,6 +114,9 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
||||
"/api/admin/auth/login",
|
||||
"/api/admin/auth/login-shops/**",
|
||||
"/api/admin/auth/refresh",
|
||||
"/admin/auth/login",
|
||||
"/admin/auth/login-shops/**",
|
||||
"/admin/auth/refresh",
|
||||
"/admin/api/auth/login",
|
||||
"/admin/api/auth/login-shops/**",
|
||||
"/admin/api/auth/refresh",
|
||||
|
||||
@@ -103,6 +103,11 @@ spring:
|
||||
- Path=/admin/api/**
|
||||
filters:
|
||||
- RewritePath=/admin/api/(?<remaining>.*), /admin/${remaining}
|
||||
- id: admin-auth-compat-route
|
||||
order: -8
|
||||
uri: lb://yumi-nail-core
|
||||
predicates:
|
||||
- Path=/admin/auth/**
|
||||
# 前台API兜底路由,避免 Core 新增模块后 Gateway 未同步导致 404
|
||||
- id: frontend-fallback-route
|
||||
order: 100
|
||||
@@ -130,6 +135,7 @@ yuminail:
|
||||
- /api/nail-artist/profile/**
|
||||
- /api/nail-artist/*/availability
|
||||
- /api/nail-artist/*/reviews
|
||||
- /api/shop/list
|
||||
- /api/shop/list/simple
|
||||
- /api/legal-agreement/current
|
||||
- /api/legal-agreement/current/**
|
||||
@@ -138,6 +144,9 @@ yuminail:
|
||||
- /api/admin/auth/login
|
||||
- /api/admin/auth/login-shops/**
|
||||
- /api/admin/auth/refresh
|
||||
- /admin/auth/login
|
||||
- /admin/auth/login-shops/**
|
||||
- /admin/auth/refresh
|
||||
- /admin/api/auth/login
|
||||
- /admin/api/auth/login-shops/**
|
||||
- /admin/api/auth/refresh
|
||||
|
||||
+26
-1
@@ -3,8 +3,10 @@ package com.xiaowang.yumitailgateway.filter;
|
||||
import com.xiaowang.yumitailgateway.config.GatewayConfig;
|
||||
import com.xiaowang.yumitailgateway.filter.AuthGlobalFilter.AuthWhitelist;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -28,10 +30,33 @@ class AuthGlobalFilterWhitelistTest {
|
||||
@Test
|
||||
void defaultWhitelistIncludesOnlyExpectedPublicBusinessAreas() {
|
||||
assertThat(AuthWhitelist.defaultPatterns())
|
||||
.contains("/api/user/login", "/api/comment/list/product/**", "/api/admin/auth/login")
|
||||
.contains(
|
||||
"/api/user/login",
|
||||
"/api/comment/list/product/**",
|
||||
"/api/admin/auth/login",
|
||||
"/admin/auth/login",
|
||||
"/api/nail-artist/profile/**",
|
||||
"/api/nail-artist/*/availability",
|
||||
"/api/nail-artist/*/reviews",
|
||||
"/api/shop/list"
|
||||
)
|
||||
.doesNotContain("/api/order/**", "/api/shop/delete/**", "/api/permission/**");
|
||||
}
|
||||
|
||||
@Test
|
||||
void directAdminLoginCompatibilityPathIsWhitelisted() {
|
||||
assertThat(matches(AuthWhitelist.defaultPatterns(), "/admin/auth/login")).isTrue();
|
||||
assertThat(matches(AuthWhitelist.defaultPatterns(), "/admin/auth/login-shops/1")).isTrue();
|
||||
assertThat(matches(AuthWhitelist.defaultPatterns(), "/admin/auth/refresh")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void applicationRoutesDirectAdminAuthCompatibilityPath() throws Exception {
|
||||
String yaml = new String(new ClassPathResource("application.yaml").getInputStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(yaml).contains("Path=/admin/auth/**");
|
||||
}
|
||||
|
||||
private boolean matches(List<String> patterns, String path) {
|
||||
return patterns.stream().anyMatch(pattern -> pathMatcher.match(pattern, path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user