fix: accounts created via CLI can't authenticate with real kosync clients - #131
Open
inaltoasinistra wants to merge 1 commit into
Open
inaltoasinistra wants to merge 1 commit into
inaltoasinistra wants to merge 1 commit into
Conversation
kosync clients always MD5-hash the password client-side before sending it, so the CLI must apply the same step the admin's typed password otherwise never matches the x-auth-key a real client presents at login.
inaltoasinistra
force-pushed
the
fix-cli-user-create
branch
from
July 28, 2026 16:54
49d6492 to
df73565
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.
Fixes #130
Summary
client-side before sending it, both at registration (
POST /users/create)and at login (
x-auth-keyheader). The server just Argon2-hashes whateverstring it receives, so it never needs to know this is happening — as long
as both the stored value and the login value went through the same
transform.
korrosync user create/korrosync user reset-passwordtook the admin'styped password literally and Argon2-hashed it as-is, skipping the MD5 step
a real client always performs. That meant CLI-created accounts stored
Argon2(password)while every real client would sendMD5(password)asx-auth-key— so login always failed with401 Unauthorized, even withthe correct password.
korrosync::model::md5_hex, and the CLI now runs the typed passwordthrough it before hashing, so CLI-created/reset accounts store the same
credential a client-driven
POST /users/createcall would produce for thesame password.
Test plan
src/model/user.rs: unit tests formd5_hex(RFC 1321 known-answervector, determinism, distinctness)
tests/user_cli_password_test.rs(new): spawns the realkorrosyncbinary to run
user create/user reset-password, then verifieslogin succeeds with the MD5-hashed key a real client sends and fails
with the raw plaintext password; also verifies a CLI-created account
and an API-registered account authenticate identically given the same
real password
cargo test,cargo fmt --check,cargo clippy --all-targets -- -D warningscurl(MD5-hashedx-auth-key→200 OK, raw plaintextx-auth-key→401)