Files
minio-webui/scripts/debug-auth.sh
T
paul 6fda151dae feat: Add authentication debug and test scripts
- Add debug-auth.sh to diagnose authentication issues
  - Checks .env file content
  - Verifies environment variables in container
  - Tests bcrypt password verification
  - Shows config loading status
  - Displays recent auth logs

- Add test-auth-api.sh to test API endpoints directly
  - Tests login endpoint with curl
  - Shows raw API responses
  - Tests auth status endpoint

These scripts help troubleshoot authentication problems by showing
exactly what's happening at each step of the auth process.

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

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

71 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
echo "======================================"
echo "MinIO WebUI - Auth Debug"
echo "======================================"
echo ""
# Check container
if docker ps | grep -q minio-webui-backend-dev; then
CONTAINER="minio-webui-backend-dev"
else
CONTAINER="minio-webui-backend"
fi
echo "1. Checking .env file on host:"
echo "------------------------------"
grep "ADMIN_PASSWORD_HASH\|JWT_SECRET" .env | head -20
echo ""
echo "2. Checking environment in container:"
echo "------------------------------------"
docker exec $CONTAINER sh -c 'echo "ADMIN_PASSWORD_HASH=$ADMIN_PASSWORD_HASH" | head -c 80'
echo ""
docker exec $CONTAINER sh -c 'echo "JWT_SECRET=$JWT_SECRET" | head -c 40'
echo ""
echo "3. Testing password directly in container:"
echo "-----------------------------------------"
docker exec $CONTAINER node -e "
const bcrypt = require('bcrypt');
const testHash = '$2b$12$LQv7c3SijBJLhSHPDOLkDe7YfPzFaXhJNXLKqFsFC37GA9xc1wSNi';
const envHash = process.env.ADMIN_PASSWORD_HASH;
console.log('Test hash (admin123):', testHash);
console.log('Env hash:', envHash ? envHash.substring(0, 20) + '...' : 'NOT SET');
console.log('Hashes match:', testHash === envHash);
bcrypt.compare('admin123', testHash).then(result => {
console.log('Test password "admin123" with hardcoded hash:', result);
});
if (envHash) {
bcrypt.compare('admin123', envHash).then(result => {
console.log('Test password "admin123" with env hash:', result);
}).catch(err => {
console.log('Error testing with env hash:', err.message);
});
}
"
echo ""
echo "4. Checking config loading:"
echo "--------------------------"
docker exec $CONTAINER node -e "
const config = require('./src/config');
console.log('Config auth:', {
hasPasswordHash: !!config.auth.adminPasswordHash,
hashLength: config.auth.adminPasswordHash ? config.auth.adminPasswordHash.length : 0,
hashPrefix: config.auth.adminPasswordHash ? config.auth.adminPasswordHash.substring(0, 7) : 'NOT SET',
hasJwtSecret: !!config.auth.jwtSecret,
env: config.app.env
});
"
echo ""
echo "5. Recent backend logs:"
echo "----------------------"
docker logs --tail 20 $CONTAINER 2>&1 | grep -E "(Password|AUTH|Login|401)"
echo ""
echo "======================================"