fix(backend): 改为后台配置注册限流阈值
This commit is contained in:
1 parent
78fb99530d
commit
f1aaaee814
8 files changed
+79
-39
No files matched your search
@@ -2,34 +2,37 @@
|
||||
|
||||
## 范围
|
||||
|
||||
将 C 端注册的 IP/设备 24 小时限流阈值从硬编码改为 Spring 配置:
|
||||
将 C 端注册的 IP/设备 24 小时限流阈值从硬编码改为后台 `sys_config` 配置:
|
||||
|
||||
```text
|
||||
fruitshorts.auth.register-max-per-ip-per-day
|
||||
fruitshorts.auth.register-max-per-device-per-day
|
||||
app.register.max-per-ip-per-day
|
||||
app.register.max-per-device-per-day
|
||||
```
|
||||
|
||||
默认值保持 5/3;值小于等于 0 时跳过对应 guard。注册接口、错误码和错误文案不变。
|
||||
键缺失或非整数时回退默认 5/3;值小于等于 0 时跳过对应 guard。注册接口、
|
||||
错误码和错误文案不变。
|
||||
|
||||
## 实现
|
||||
|
||||
1. `AppAuthService` 用 `@Value` 字段注入阈值,保留现有 Lombok 构造器。
|
||||
2. 开发 `application.yml` 显式配置 0/0,并注释生产建议 5/3。
|
||||
3. `application-prod.yml` 显式配置 5/3。
|
||||
4. `docs/api-phase1.md` §1.1 补充配置键和 0=不限制口径。
|
||||
5. 测试用 `ReflectionTestUtils` 注入阈值,覆盖 IP/设备超限、IP 不限制、设备不限制。
|
||||
1. `AppAuthService` 注入 `ConfigService`,从 `sys_config` 读取两个键。
|
||||
2. `sql/data-phase1.sql` 幂等写入开发默认 0/0 和说明。
|
||||
3. 不使用 `application.yml` 固化限流值。
|
||||
4. `docs/api-phase1.md` §1.1 补充后台配置键、缺省/非法回退和 0=不限制口径。
|
||||
5. 测试 mock `ConfigService`,覆盖自定义、0、缺省/非数字回退。
|
||||
6. 确认后台「系统设置」页面可访问 `/admin/configs`;若现有表单未展示新键,
|
||||
记录为待后续 Web 表单补充,不把配置固化回 yml。
|
||||
|
||||
## 验证与交付
|
||||
|
||||
- `mvn test`
|
||||
- `mvn -pl fruitshorts-app-api -am package -DskipTests`
|
||||
- 停止当前 8081 PID 30520,启动新 jar,`/healthz` 通过
|
||||
- 停止当前 8081 服务,启动新 jar,`/healthz` 通过
|
||||
- 使用新设备号连续注册至少 4 次,确认不再 429(接口自检)
|
||||
- `feature/backend-register-rate-config` 以 `--no-ff` 合并回 `develop` 并 push
|
||||
- `feature/backend-register-rate-config-fix` 以 `--no-ff` 合并回 `develop` 并 push
|
||||
- PROGRESS 记录命令、原始输出和解读
|
||||
|
||||
## 风险
|
||||
|
||||
- 配置 0 会关闭注册滥用保护,仅用于当前开发环境;prod profile 固定恢复 5/3。
|
||||
- 配置 0 会关闭注册滥用保护,仅用于当前开发环境;生产需在后台恢复 5/3。
|
||||
- 旧 8081 服务重启期间会有短暂不可用。
|
||||
- 限流仍基于客户端可伪造 IP/设备号,本次不放宽其他风控。
|
||||
Reference in new issue
Block a user