Repository navigation
feat(auth): compare-and-swap on wrapped user secrets uploads - #111
Merged
Merged
Conversation
A device repairing its stored team identity must not overwrite a password change made on another device. The upload now names the value it replaces and the server answers 409 when the row holds something else.
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.
PUT /v1/auth/wrapped-user-secretsnow takes an optionalexpected_wrapped_user_secretsand only writes when the stored value matches it (IS NOT DISTINCT FROM, one atomic UPDATE). On a mismatch it returns 409. A request that omits the field expects NULL. The legacy migration, the only existing caller, runs only when the value is NULL, so released clients behave exactly as before.GET /v1/metaadvertiseswrapped_secrets_cas: true. Clients must not write wrapped secrets on a server that lacks the flag.Why: the client branch VoltiusApp/voltius
fix/identity-off-vault-keymoves the team identity into the wrapped secrets and repairs the stored copy on any device that finds the right key. Without this check, a device holding stale secrets could overwrite a password change made on another device. The account would then no longer open with the new password.Deploy before the client. A client from that branch never writes without the flag, so the order is safe either way. The flag is what turns the repair on.
Tests: 3 DB-backed handler tests (first upload with no expectation, replace only the expected value, refuse an overwrite without an expectation) and a meta test. The full suite passes (734). Clippy is clean.
It was also exercised end to end against a client build. A stale device's overwrite was refused with 409, and the new password's secrets stayed intact.