LukeMathWalker / LukeMathWalker/zero-to-production
10.2.5 `unknown username` won't be returned
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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