功能:落地待优化建议与VIP资产联动
This commit is contained in:
+45
-25
@@ -55,6 +55,8 @@
|
||||
- 验证token是否过期、是否为accessToken类型
|
||||
- 从token中提取用户信息并设置到请求属性中
|
||||
- 订单创建时还会校验购物车归属、同店铺/同美甲师约束、预约时间有效性、门店营业时间以及美甲师已有预约冲突
|
||||
- 用户资产相关操作改为通过 `UserAssetService` 统一事务处理,保证余额、累计充值、流水、VIP 状态一次提交
|
||||
- 订单结算会区分 `USER_COUPON` 与 `SYSTEM_VIP` 两类优惠来源;未显式选券时只自动补用最佳 VIP 自动券,不会自动消耗普通用户券
|
||||
|
||||
3. **权限控制**:
|
||||
- 后端使用@RequirePermission注解进行权限控制
|
||||
@@ -70,47 +72,65 @@
|
||||
const isWhitelistedPath = (url: string) => {
|
||||
return url?.includes('/user/login') ||
|
||||
url?.includes('/user/register') ||
|
||||
url?.includes('/user/check/') ||
|
||||
url?.includes('/user/refresh-token') ||
|
||||
url?.includes('/user/send-verification-code') ||
|
||||
url?.includes('/user/phone-login') ||
|
||||
url?.includes('/shop/list/simple') ||
|
||||
url?.includes('/admin/login')
|
||||
url?.includes('/admin/auth/login') ||
|
||||
url?.includes('/admin/auth/refresh')
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 网关白名单
|
||||
|
||||
在`YumiNail-Gateway/src/main/java/com/xiaowang/yumitailgateway/filter/AuthGlobalFilter.java`中定义:
|
||||
在`YumiNail-Gateway/src/main/resources/application.yaml`中通过配置集中维护:
|
||||
|
||||
```java
|
||||
private boolean isWhitelist(String path) {
|
||||
return path.equals("/api/user/login") ||
|
||||
path.equals("/api/user/register") ||
|
||||
path.equals("/api/user/refresh-token") ||
|
||||
path.equals("/api/shop/list/simple") ||
|
||||
path.equals("/api/admin/auth/login") ||
|
||||
path.equals("/admin/api/auth/login") ||
|
||||
path.startsWith("/api/user/get/account") ||
|
||||
path.startsWith("/api/health");
|
||||
}
|
||||
```yaml
|
||||
yuminail:
|
||||
gateway:
|
||||
whitelist:
|
||||
- /api/user/login
|
||||
- /api/user/register
|
||||
- /api/user/check/**
|
||||
- /api/user/refresh-token
|
||||
- /api/user/send-verification-code
|
||||
- /api/user/phone-login
|
||||
- /api/user/reset-password-by-phone
|
||||
- /api/shop/list/simple
|
||||
- /api/health/**
|
||||
- /api/admin/auth/login
|
||||
- /api/admin/auth/refresh
|
||||
```
|
||||
|
||||
### 3.3 核心服务白名单
|
||||
|
||||
在`YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/config/AuthInterceptor.java`中定义:
|
||||
在`YumiNail-Core/src/main/java/com/xiaowang/yuminailcore/config/WebMvcConfig.java`中定义:
|
||||
|
||||
```java
|
||||
private boolean isWhitelistedPath(String path) {
|
||||
return path.contains("/user/login") ||
|
||||
path.contains("/user/register") ||
|
||||
path.contains("/user/refresh-token") ||
|
||||
path.contains("/user/get/account") ||
|
||||
path.contains("/shop/list/simple") ||
|
||||
path.contains("/admin/auth/login") ||
|
||||
path.contains("/admin/object-storage-file/upload") ||
|
||||
path.contains("/health") ||
|
||||
path.contains("/error");
|
||||
}
|
||||
registry.addInterceptor(authInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(
|
||||
"/user/login",
|
||||
"/user/register",
|
||||
"/user/check/**",
|
||||
"/user/refresh-token",
|
||||
"/user/send-verification-code",
|
||||
"/user/phone-login",
|
||||
"/user/reset-password-by-phone",
|
||||
"/shop/list/simple",
|
||||
"/admin/auth/login",
|
||||
"/admin/auth/refresh",
|
||||
"/error",
|
||||
"/health/**"
|
||||
);
|
||||
```
|
||||
|
||||
### 3.4 白名单补充说明
|
||||
|
||||
- 账号检测链路 `GET /api/user/check/account/{account}`、`GET /api/user/check/phone/{phone}`、`GET /api/user/check/login-account/{account}` 必须同时在前端、网关、本地 Core 拦截器以及 Nacos `YumiNail-Dev` 白名单中保持一致。
|
||||
- 白名单只开放登录、注册、验证码、刷新 token、店铺简表、健康检查与账号检测接口;其余用户资产、订单、购物车、后台管理接口仍必须携带 token。
|
||||
|
||||
## 4. 权限控制体系
|
||||
|
||||
### 4.1 前端权限控制
|
||||
|
||||
Reference in New Issue
Block a user