mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd/database): add AI Gateway key auth lookup and last-used queries (#26505)
Adds DB methods`GetAIGatewayKeyIDByHashedSecret` and `UpdateAIGatewayKeyLastUsedAt`. `GetAIGatewayKeyIDByHashedSecret` - returns AI Gateway key ID by hashed secret value. `UpdateAIGatewayKeyLastUsedAt` - updates last used timestamp for given AI Gateway key. Used by standalone AI Gateway for authentication and keeping track of currently used keys.
This commit is contained in:
Generated
+4
-1
@@ -386,6 +386,7 @@ const (
|
||||
ApiKeyScopeAIGatewayKeyCreate APIKeyScope = "ai_gateway_key:create"
|
||||
ApiKeyScopeAIGatewayKeyDelete APIKeyScope = "ai_gateway_key:delete"
|
||||
ApiKeyScopeAIGatewayKeyRead APIKeyScope = "ai_gateway_key:read"
|
||||
ApiKeyScopeAIGatewayKeyUpdate APIKeyScope = "ai_gateway_key:update"
|
||||
)
|
||||
|
||||
func (e *APIKeyScope) Scan(src interface{}) error {
|
||||
@@ -654,7 +655,8 @@ func (e APIKeyScope) Valid() bool {
|
||||
ApiKeyScopeAIGatewayKey,
|
||||
ApiKeyScopeAIGatewayKeyCreate,
|
||||
ApiKeyScopeAIGatewayKeyDelete,
|
||||
ApiKeyScopeAIGatewayKeyRead:
|
||||
ApiKeyScopeAIGatewayKeyRead,
|
||||
ApiKeyScopeAIGatewayKeyUpdate:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -892,6 +894,7 @@ func AllAPIKeyScopeValues() []APIKeyScope {
|
||||
ApiKeyScopeAIGatewayKeyCreate,
|
||||
ApiKeyScopeAIGatewayKeyDelete,
|
||||
ApiKeyScopeAIGatewayKeyRead,
|
||||
ApiKeyScopeAIGatewayKeyUpdate,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user