- Add simple hash-password script for quick hash generation - Add interactive generate-password script with hidden input - Include password validation and requirements display - Add npm scripts for easy execution - Create comprehensive PASSWORD_GENERATION.md guide - Use existing bcrypt infrastructure with 12 salt rounds Usage: npm run hash-password YourPassword123\! npm run generate-password (interactive) This solves the issue where bcrypt command line tools don't work properly for generating compatible hashes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.6 KiB
Password Generation Guide for MinIO WebUI
Quick Start
Method 1: Simple Command (Recommended)
cd backend
npm run hash-password YourSecurePassword123!
This will output:
=== Generated Password Hash ===
ADMIN_PASSWORD_HASH=$2b$12$...your.hash.here...
Copy the above line to your .env file
Method 2: Interactive Mode
cd backend
npm run generate-password
This will:
- Prompt you for a password (hidden input)
- Generate the bcrypt hash
- Show you the hash to copy to your .env file
- Verify the hash works correctly
Docker Usage
If you're using Docker, you can run the password generator inside the container:
# Method 1: Quick hash
docker exec -it minio-webui-backend npm run hash-password YourPassword123!
# Method 2: Interactive
docker exec -it minio-webui-backend npm run generate-password
Password Requirements
Your password should meet these criteria:
- Minimum 8 characters
- At least one uppercase letter (A-Z)
- At least one lowercase letter (a-z)
- At least one number (0-9)
- At least one special character (!@#$%^&* etc.)
Example Passwords
Good passwords:
MySecure@Pass123Admin#2024!StrongMinIO$WebUI&Safe99
Step-by-Step Instructions
-
Navigate to backend directory:
cd backend -
Generate your password hash:
npm run hash-password MyChosenPassword123! -
Copy the output (it will look like this):
ADMIN_PASSWORD_HASH=$2b$12$abcdefghijklmnopqrstuvwxyz... -
Add to your .env file:
# Edit your .env file nano ../.env # Or append directly echo "ADMIN_PASSWORD_HASH=\$2b\$12\$your_hash_here" >> ../.env -
Restart the backend:
# If using Docker docker-compose restart backend # If running locally npm start
Troubleshooting
"bcrypt: command not found"
The script uses the Node.js bcrypt library, not the system bcrypt. Make sure you're in the backend directory and have run npm install.
"Cannot find module 'bcrypt'"
Install dependencies first:
cd backend
npm install
Hash not working
- Make sure you copied the entire hash including the
$2b$12$prefix - Check for any extra spaces or line breaks
- Ensure the .env file is in the project root directory
- Try generating a new hash
Special characters in password
If your password contains special shell characters, wrap it in single quotes:
npm run hash-password 'My$uper!Pass@123'
Security Notes
- Never commit your .env file to version control
- Use strong passwords - the hash is only as secure as your password
- Change default passwords immediately in production
- Store .env securely with appropriate file permissions:
chmod 600 .env
Advanced Usage
Custom Salt Rounds
The scripts use 12 salt rounds by default (recommended). If you need to change this, edit the script:
const saltRounds = 12; // Change this value if needed
Higher numbers are more secure but slower to compute.
Verify a Hash
To verify if a password matches a hash:
// In Node.js
const bcrypt = require('bcrypt');
const isValid = await bcrypt.compare('YourPassword', '$2b$12$...');
console.log(isValid); // true or false
Integration with MinIO WebUI
Once you've set the ADMIN_PASSWORD_HASH in your .env file:
- Start/restart the application
- Navigate to the login page
- Username:
admin(fixed) - Password: The password you used to generate the hash
The application will compare your entered password with the stored hash for authentication.