db: store all credentials in one argon2id-hashed table - #3352
Draft
kradalby wants to merge 5 commits into
Draft
Conversation
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
force-pushed
the
unify-credentials
branch
from
June 27, 2026 12:21
067b6c2 to
e600822
Compare
Backfill keeping ids, retarget the nodes FK to credentials(id), drop the four per-kind tables. Node.AuthKey becomes a *Credential association.
kradalby
force-pushed
the
unify-credentials
branch
from
June 27, 2026 12:51
e600822 to
04e8fcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
credentialstable discriminated bykind, on the argon2id core (hashSecret/verifySecret) OAuth already used.verifySecretnow 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.AuthKeybecomes a*Credentialassociation;nodes.auth_key_idkeeps a real foreign key, retargeted tocredentials(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.