Refine scoped API key capabilities

This commit is contained in:
wizardchen
2026-07-07 11:09:10 +08:00
committed by lyingbug
parent b5cc7d2a28
commit 2c6f082062
38 changed files with 1718 additions and 655 deletions
@@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS tenant_api_keys (
name VARCHAR(128) NOT NULL,
key_hash VARCHAR(64) NOT NULL UNIQUE,
api_key TEXT NOT NULL DEFAULT '',
role VARCHAR(32) NOT NULL DEFAULT 'viewer',
full_access BOOLEAN NOT NULL DEFAULT FALSE,
knowledge_base_ids JSONB NOT NULL DEFAULT '[]'::jsonb,
last_used_at TIMESTAMP,
expires_at TIMESTAMP,
@@ -25,7 +25,7 @@ INSERT INTO tenant_api_keys (
name,
key_hash,
api_key,
role,
full_access,
knowledge_base_ids,
created_at,
updated_at
@@ -35,7 +35,7 @@ SELECT
'Tenant API key',
'migrated-tenant-' || id::text,
api_key,
'owner',
TRUE,
'[]'::jsonb,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP