Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 341bdfe

Browse files
author
bitfl0wer
committed
feat: better solution for user tokens without cert_id
1 parent 9f77cd6 commit 341bdfe

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

migrations/0007_api_keys.sql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ CREATE TABLE IF NOT EXISTS api_keys (
44
CONSTRAINT token_length CHECK (length(token) >= 24 AND length(token) <= 255)
55
);
66

7-
-- TODO: This should account for an "initial" token, like after registering successfully/logging in
8-
-- the first time, without having any idcerts. another table could help
97
CREATE TABLE IF NOT EXISTS user_tokens (
108
token_hash VARCHAR(255) PRIMARY KEY,
11-
cert_id BIGINT NOT NULL REFERENCES idcert (idcsr_id),
129
uaid UUID NOT NULL REFERENCES actors (uaid) ON DELETE CASCADE,
13-
valid_not_after TIMESTAMP NULL
10+
valid_not_after TIMESTAMP NULL,
11+
cert_id BIGINT NOT NULL REFERENCES idcert (idcsr_id),
12+
UNIQUE NULLS NOT DISTINCT (uaid, cert_id)
1413
);
1514

1615
COMMENT ON TABLE user_tokens IS 'User access token hashes. Cleans up expired tokens on each insert operation of this table. Use view filtering to exclude expired tokens on queries.';

0 commit comments

Comments
 (0)