feat(api-key): 添加 IP 白名单/黑名单限制功能 (#221)
* feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support) - Add IP address logging to usage logs (admin-only visibility) - Remove billing_type column from usage logs UI (redundant) - Use generic "Access denied" error message for security Backend: - New ip package with IP/CIDR validation and matching utilities - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs) - Middleware IP restriction check after API key validation - Input validation for IP/CIDR patterns on create/update Frontend: - API key form with enable toggle for IP restriction - Shield icon indicator in table for keys with IP restriction - Removed billing_type filter and column from usage views * fix: update API contract tests for ip_whitelist/ip_blacklist fields Add ip_whitelist and ip_blacklist fields to expected JSON responses in API contract tests to match the new API key schema.
This commit is contained in:
@@ -370,6 +370,14 @@ export default {
|
||||
customKeyTooShort: 'Custom key must be at least 16 characters',
|
||||
customKeyInvalidChars: 'Custom key can only contain letters, numbers, underscores, and hyphens',
|
||||
customKeyRequired: 'Please enter a custom key',
|
||||
ipRestriction: 'IP Restriction',
|
||||
ipWhitelist: 'IP Whitelist',
|
||||
ipWhitelistPlaceholder: '192.168.1.100\n10.0.0.0/8',
|
||||
ipWhitelistHint: 'One IP or CIDR per line. Only these IPs can use this key when set.',
|
||||
ipBlacklist: 'IP Blacklist',
|
||||
ipBlacklistPlaceholder: '1.2.3.4\n5.6.0.0/16',
|
||||
ipBlacklistHint: 'One IP or CIDR per line. These IPs will be blocked from using this key.',
|
||||
ipRestrictionEnabled: 'IP restriction enabled',
|
||||
ccSwitchNotInstalled: 'CC-Switch is not installed or the protocol handler is not registered. Please install CC-Switch first or manually copy the API key.',
|
||||
ccsClientSelect: {
|
||||
title: 'Select Client',
|
||||
@@ -430,9 +438,6 @@ export default {
|
||||
exportFailed: 'Failed to export usage data',
|
||||
exportExcelSuccess: 'Usage data exported successfully (Excel format)',
|
||||
exportExcelFailed: 'Failed to export usage data',
|
||||
billingType: 'Billing',
|
||||
balance: 'Balance',
|
||||
subscription: 'Subscription',
|
||||
imageUnit: ' images',
|
||||
userAgent: 'User-Agent'
|
||||
},
|
||||
@@ -1735,7 +1740,6 @@ export default {
|
||||
allAccounts: 'All Accounts',
|
||||
allGroups: 'All Groups',
|
||||
allTypes: 'All Types',
|
||||
allBillingTypes: 'All Billing',
|
||||
inputCost: 'Input Cost',
|
||||
outputCost: 'Output Cost',
|
||||
cacheCreationCost: 'Cache Creation Cost',
|
||||
@@ -1744,7 +1748,8 @@ export default {
|
||||
outputTokens: 'Output Tokens',
|
||||
cacheCreationTokens: 'Cache Creation Tokens',
|
||||
cacheReadTokens: 'Cache Read Tokens',
|
||||
failedToLoad: 'Failed to load usage records'
|
||||
failedToLoad: 'Failed to load usage records',
|
||||
ipAddress: 'IP'
|
||||
},
|
||||
|
||||
// Settings
|
||||
|
||||
Reference in New Issue
Block a user