mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 16:06:08 +00:00
Support optional custom client keys across creation, storage, and authentication. Search keys and request records by name, remove credential and prefix searches, and reject duplicate names during create and update using the existing control-plane transaction lock. Simplify the request diagnostics panel and use the shared empty state. Validated with 1,029 backend tests using dedicated PostgreSQL and Redis, strict workspace Clippy, frontend lint/typecheck/build, and browser checks for key creation, name validation, search, diagnostics refresh/export, and mobile layouts. Co-authored-by: Codex <noreply@openai.com>
18 lines
790 B
SQL
18 lines
790 B
SQL
-- 保留旧 Key,允许迁入不同前缀、长度和标点;约束与 HTTP Bearer 可见字符一致。
|
|
alter table client_api_keys
|
|
drop constraint client_api_keys_key_ck,
|
|
add constraint client_api_keys_key_ck check (
|
|
key <> '' and key collate "C" !~ '[^!-~]'
|
|
);
|
|
|
|
-- 可见 ASCII 在 UTF-8 中编码固定,因此这里可声明 immutable。
|
|
-- 对完整值建固定大小的摘要索引,避免长 Key 超过 PostgreSQL B-tree 索引项上限。
|
|
create function client_api_key_sha256(value text) returns bytea
|
|
language sql immutable strict parallel safe
|
|
return sha256(convert_to(value, 'UTF8'));
|
|
|
|
create unique index client_api_keys_key_sha256_idx
|
|
on client_api_keys (client_api_key_sha256(key));
|
|
|
|
alter table client_api_keys drop constraint client_api_keys_key_key;
|