mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-24 23:21:18 +00:00
feat(api-key): 增加 API Key 创建数量与频率限制
- 新增 api_key_create.max_active_per_user(默认 200)与 api_key_create.max_per_user_per_hour(默认 20),0 表示不限制 - 创建频率按固定一小时窗口统计,自定义与自动生成的 Key 统一计入 - 创建计数独立于 Key 生命周期,删除或修改 Key 不再重置计数 - 移除不再使用的 DeleteCreateAttemptCount 缓存方法
This commit is contained in:
1 parent
a0f41f95a0
commit
9ecb340822
12 files changed
+302
-48
No files matched your search
@@ -67,8 +67,10 @@ func (*authInvalidationCacheStub) GetCreateAttemptCount(context.Context, int64)
|
||||
func (*authInvalidationCacheStub) IncrementCreateAttemptCount(context.Context, int64) error {
|
||||
return nil
|
||||
}
|
||||
func (*authInvalidationCacheStub) DeleteCreateAttemptCount(context.Context, int64) error { return nil }
|
||||
func (*authInvalidationCacheStub) IncrementDailyUsage(context.Context, string) error { return nil }
|
||||
func (*authInvalidationCacheStub) IncrementCreateCount(context.Context, int64, time.Duration) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
func (*authInvalidationCacheStub) IncrementDailyUsage(context.Context, string) error { return nil }
|
||||
func (*authInvalidationCacheStub) SetDailyUsageExpiry(context.Context, string, time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user