Files
minio-webui/scripts/test-password.sh
T
paul 2ee293244c feat: Add password generation and testing scripts
- Add generate-password.js for Node.js password hash generation
- Add generate-password-docker.sh for Docker-based generation
- Add test-password.sh to verify password against current hash

These scripts help users generate correct bcrypt hashes for the
ADMIN_PASSWORD_HASH environment variable.

Usage:
- Generate new hash: ./scripts/generate-password-docker.sh
- Test current password: ./scripts/test-password.sh

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 15:11:48 +02:00

48 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
echo "================================="
echo "MinIO WebUI Password Tester"
echo "================================="
echo ""
# Check if .env file exists
if [ ! -f .env ]; then
echo "Error: .env file not found"
exit 1
fi
# Get the hash from .env
HASH=$(grep ADMIN_PASSWORD_HASH .env | cut -d '=' -f2-)
if [ -z "$HASH" ]; then
echo "Error: ADMIN_PASSWORD_HASH not found in .env"
exit 1
fi
echo "Current hash in .env: ${HASH:0:20}..."
echo ""
read -s -p "Enter password to test: " PASSWORD
echo ""
# Test the password using Node.js in Docker
docker run --rm node:20-alpine sh -c "
npm install bcrypt >/dev/null 2>&1 && \
node -e \"
const bcrypt = require('bcrypt');
const hash = '$HASH';
const password = '$PASSWORD';
bcrypt.compare(password, hash).then(result => {
if (result) {
console.log('\n✅ Password is CORRECT!');
} else {
console.log('\n❌ Password is INCORRECT!');
}
}).catch(err => {
console.error('\n❌ Error:', err.message);
});
\"
"
echo ""
echo "================================="