feat: make Argon2 parameters configurable for faster test execution#239
Conversation
This change makes Argon2 password hashing parameters (memory, iterations, parallelism) configurable through PasswordConfig, with weak defaults in test environments for dramatically faster test execution. ## Changes - Added `argon2_memory_kib`, `argon2_iterations`, and `argon2_parallelism` to `PasswordConfig` (defaults: 19MB, 2 iterations, 1 thread for production) - Test config uses weak params (128KB, 1 iteration) for fast execution - Updated all password hashing calls to use configurable parameters - Added `hash_string_with_params()` function to accept custom Argon2 params ## Performance Impact Auth test suite with coverage: - Before (19MB, 2 iter): 15.38s - After (128KB, 1 iter): 0.67s - **23x faster** test execution with coverage This resolves the issue where `cargo llvm-cov` was significantly slower than `cargo test` due to instrumenting Argon2's internal hashing loops. Tests now run faster even with coverage enabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
🚅 Environment control-layer-pr-239 in industrious-light has no services deployed. |
|
@fergusfinn I've opened a new pull request, #240, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable Argon2 password hashing parameters to dramatically improve test execution speed while maintaining secure defaults for production. The test suite now runs in 0.67s (down from 15.38s) by using weak hashing parameters (128KB memory, 1 iteration) instead of production defaults (19MB, 2 iterations).
Key changes:
- Added three configurable Argon2 parameters to
PasswordConfig:argon2_memory_kib,argon2_iterations, andargon2_parallelism - Introduced
Argon2Paramsstruct andhash_string_with_paramsfunction for explicit parameter control - Updated all password hashing call sites to pass configuration-based parameters
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
dwctl/src/auth/password.rs |
Adds Argon2Params struct and parameterized hashing functions, maintaining backward compatibility with hash_string() |
dwctl/src/config.rs |
Extends PasswordConfig with Argon2 parameters using secure production defaults (19MB, 2 iterations) |
dwctl/src/test_utils.rs |
Configures weak Argon2 parameters (128KB, 1 iteration) for fast test execution |
dwctl/src/lib.rs |
Updates create_initial_admin_user to accept Argon2Params and use config values; updates test calls with weak params |
dwctl/src/api/handlers/auth.rs |
Extracts Argon2 params from config in registration, password reset, and password change handlers; updates all test fixtures with weak params |
dwctl/src/db/models/password_reset_tokens.rs |
Adds argon2_params field to PasswordResetTokenCreateRequest for token hashing |
dwctl/src/db/handlers/password_reset_tokens.rs |
Passes Argon2 params from config when creating password reset tokens |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@fergusfinn I've opened a new pull request, #241, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * refactor: remove unnecessary verify_string_with_params wrapper Co-authored-by: fergusfinn <6034059+fergusfinn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fergusfinn <6034059+fergusfinn@users.noreply.github.com>
…239) * feat: make Argon2 parameters configurable for faster test execution This change makes Argon2 password hashing parameters (memory, iterations, parallelism) configurable through PasswordConfig, with weak defaults in test environments for dramatically faster test execution. ## Changes - Added `argon2_memory_kib`, `argon2_iterations`, and `argon2_parallelism` to `PasswordConfig` (defaults: 19MB, 2 iterations, 1 thread for production) - Test config uses weak params (128KB, 1 iteration) for fast execution - Updated all password hashing calls to use configurable parameters - Added `hash_string_with_params()` function to accept custom Argon2 params ## Performance Impact Auth test suite with coverage: - Before (19MB, 2 iter): 15.38s - After (128KB, 1 iter): 0.67s - **23x faster** test execution with coverage This resolves the issue where `cargo llvm-cov` was significantly slower than `cargo test` due to instrumenting Argon2's internal hashing loops. Tests now run faster even with coverage enabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove unnecessary verify_string_with_params wrapper (#240) * Initial plan * refactor: remove unnecessary verify_string_with_params wrapper Co-authored-by: fergusfinn <6034059+fergusfinn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fergusfinn <6034059+fergusfinn@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: fergusfinn <6034059+fergusfinn@users.noreply.github.com>
This change makes Argon2 password hashing parameters (memory, iterations, parallelism) configurable through PasswordConfig, with weak defaults in test environments for dramatically faster test execution.
Performance Impact
Auth test suite with coverage:
This resolves the issue where
cargo llvm-covwas significantly slower thancargo test(i think?) due to instrumenting Argon2's internal hashing loops.