Skip to content

db: store all credentials in one argon2id-hashed table - #3352

Draft
kradalby wants to merge 5 commits into
juanfont:mainfrom
kradalby:unify-credentials
Draft

db: store all credentials in one argon2id-hashed table#3352
kradalby wants to merge 5 commits into
juanfont:mainfrom
kradalby:unify-credentials

Conversation

@kradalby

Copy link
Copy Markdown
Collaborator

Four credential kinds — API keys, pre-auth keys, OAuth clients, OAuth access tokens — each had its own table, model, and near-duplicate generate/hash/verify code, split across two hash algorithms (bcrypt for API and pre-auth keys, argon2id for OAuth).

Collapses them into one credentials table discriminated by kind, on the argon2id core (hashSecret/verifySecret) OAuth already used. verifySecret now accepts both algorithms; a matched bcrypt hash is re-hashed to argon2id on the next successful auth, so existing keys keep working and converge over time. New keys are argon2id from creation.

The four Go types stay as read projections over the table, so state, the REST API, and the CLI are untouched. Node.AuthKey becomes a *Credential association; nodes.auth_key_id keeps a real foreign key, retargeted to credentials(id). The migration backfills pre-auth keys first, preserving their ids so node references stay valid, then drops the four old tables.

Breaking: legacy plaintext pre-auth keys (pre-2025-11) are no longer accepted. bcrypt verification stays through 0.30/0.31 and is removed in 0.32 — any key unused by then must be regenerated.

Generated with the help of an AI assistant

kradalby added 4 commits June 27, 2026 12:19
Share the OAuth argon2id core across all kinds; verifySecret also accepts
bcrypt and rehashes on next auth. Plaintext pre-auth keys no longer accepted.
One store for every credential kind, keyed by kind. Additive; cutover follows.
Via the APIKey projection, leaving callers unchanged.
Via the OAuthClient and OAuthAccessToken projections.
@kradalby
kradalby force-pushed the unify-credentials branch from 067b6c2 to e600822 Compare June 27, 2026 12:21
Backfill keeping ids, retarget the nodes FK to credentials(id), drop the four
per-kind tables. Node.AuthKey becomes a *Credential association.
@kradalby
kradalby force-pushed the unify-credentials branch from e600822 to 04e8fcd Compare June 27, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant