Argon2
Add advanced Argon2 password hashing to Medusa
MedusaJS Argon2 Authentication Plugin
๐ Enhanced password hashing for MedusaJS using the Argon2 algorithm - the most advanced and secure password hashing method.
๐ Features
- Utilizes Argon2, the winner of the Password Hashing Competition
- Highly configurable password hashing
- Provides robust protection against various password cracking techniques
- Seamless integration with MedusaJS authentication
๐ก๏ธ Why Argon2?
Argon2 offers superior security compared to traditional hashing methods:
- Resistant to GPU and ASIC cracking attempts
- Configurable memory, time, and parallelism costs
- Adaptable to changing computational power
- Recommended by leading security experts
๐ฆ Installation
Install the package using npm:
1npm install @vymalo/medusa-argon2
Or using yarn:
1yarn add @vymalo/medusa-argon2
๐ Usage
Add the plugin to the Copy to clipboardmodules
section of your MedusaJS configuration:
1234567891011121314151617181920modules: [{resolve: '@medusajs/medusa/auth',options: {providers: [{resolve: '@vymalo/medusa-argon2',id: 'emailpass', // Yes, `emailpass`, as the goal is to override the defaultoptions: {// Optional configuration parametersargon2: {timeCost: 3,memoryCost: 12288, // 12 MBparallelism: 1}},},],},},
๐ง Configuration Options
The plugin supports full Argon2 configuration:
12345678910111213interface Argon2Options {hashLength?: number; // Length of the hash output (default: secure)timeCost?: number; // Number of iterations (higher = more secure)memoryCost?: number; // Memory usage in KB (higher = more secure)parallelism?: number; // Number of parallel threadstype?: 0 | 1 | 2; // Argon2 variant (d, i, or id)version?: number; // Argon2 version// Advanced optionssalt?: Buffer; // Custom salt (usually auto-generated)associatedData?: Buffer; // Additional context datasecret?: Buffer; // Secret key for additional security}
Recommended Configuration
- Copy to clipboard
timeCost
: Minimum 3, increase for more security - Copy to clipboard
memoryCost
: At least 12288 KB (12 MB) - Copy to clipboard
parallelism
: 1-4 depending on your server - Copy to clipboard
type
: Recommended Copy to clipboard2
(Argon2id - hybrid mode)
๐ก๏ธ Security Recommendations
- Always use environment variables for sensitive configurations
- Periodically review and adjust hashing parameters
- Monitor computational resources and update costs as hardware evolves
๐ค Contributing
Contributions are welcome! Please submit pull requests or open issues.
๐ Security Reporting
If you discover a security vulnerability, please send an email to [your security contact].