Files
ai-gateway-go/migrations/000008_oidc.sql
T
superidou 5759c1862e AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。
含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-12 11:45:54 +08:00

32 lines
1.4 KiB
SQL

CREATE TABLE IF NOT EXISTS gateway.identity_providers (
id uuid PRIMARY KEY,
code text NOT NULL UNIQUE,
kind varchar(16) NOT NULL CHECK (kind IN ('oidc')),
display_name varchar(128) NOT NULL,
issuer_url text NOT NULL,
client_id text NOT NULL,
encrypted_credentials bytea NOT NULL,
credential_kek_version integer NOT NULL,
redirect_uri text NOT NULL,
portal_return_url text NOT NULL,
scopes text[] NOT NULL DEFAULT ARRAY['openid', 'profile', 'email'],
auto_provision boolean NOT NULL DEFAULT false,
default_department_id uuid REFERENCES gateway.departments(id),
enabled boolean NOT NULL DEFAULT false,
revision bigint NOT NULL DEFAULT 1,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
updated_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
ALTER TABLE gateway.portal_users
ADD COLUMN IF NOT EXISTS identity_provider_id uuid
REFERENCES gateway.identity_providers(id);
DROP INDEX IF EXISTS gateway.portal_users_external_subject_idx;
CREATE UNIQUE INDEX IF NOT EXISTS portal_users_provider_subject_idx
ON gateway.portal_users (identity_provider_id, external_subject)
WHERE identity_provider_id IS NOT NULL AND external_subject IS NOT NULL;
COMMENT ON TABLE gateway.identity_providers IS
'OIDC provider registry. Client secrets are encrypted with a dedicated AEAD purpose.';