LukeMathWalker / LukeMathWalker/zero-to-production

10.2.5 `unknown username` won't be returned

Open
#253 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6.5k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

Since we use a default PHC string to make the verifying time-constant, the actual `Unknown Username` case will be early returned as `Invalid password`.
```rust
spawn_blocking_with_tracing(move || {
verify_password_hash(expected_password_hash, credentials.password)
})
.await
// early return
.context("Failed to spawn blocking task.")??;
user_id
// dead code
.ok_or_else(|| anyhow::anyhow!("Unknown username."))
.map_err(AuthError::InvalidCredentials)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the authentication entry point containing the shown spawn_blocking_with_tracing call, then inspect verify_password_hash and the user_id handling around it. Reproduce the unknown-username case and verify that it returns the intended unknown-username error instead of Invalid password while preserving the constant-time verification behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.