From c2e74656453630a96afbc665276352dfc37be2cc Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 23 Jul 2025 15:42:16 +0200 Subject: [PATCH] fix: Add environment variable truncation fix documentation and verification script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Document the solution for Docker environment variable truncation issue - Add verification script to test the fix - Include proper .env configuration with quoted values - Add Docker network (172.20.0.0/16) to allowed IPs The fix ensures bcrypt hashes and other values with special characters are properly passed to Docker containers without truncation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- docs/FIX_ENV_TRUNCATION.md | 47 ++++++++++++++++++++++++++++++++++++++ scripts/verify-env-fix.sh | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 docs/FIX_ENV_TRUNCATION.md create mode 100755 scripts/verify-env-fix.sh diff --git a/docs/FIX_ENV_TRUNCATION.md b/docs/FIX_ENV_TRUNCATION.md new file mode 100644 index 0000000..cc318b4 --- /dev/null +++ b/docs/FIX_ENV_TRUNCATION.md @@ -0,0 +1,47 @@ +# Environment Variable Truncation Fix + +## Issue +Environment variables with special characters (like `$` in bcrypt hashes) were being truncated when passed to Docker containers, causing authentication failures. + +## Solution + +1. **Created proper .env file** with quoted values: + ```bash + ADMIN_PASSWORD_HASH='$2b$12$LQv7c3SijBJLhSHPDOLkDe7YfPzFaXhJNXLKqFsFC37GA9xc1wSNi' + JWT_SECRET='your-very-long-secret-key-that-should-be-at-least-32-characters-long' + ``` + +2. **Added Docker network to ALLOWED_IPS**: + - Added `172.20.0.0/16` to support Docker's default bridge network + - This allows testing from the Docker host + +3. **Default credentials**: + - Password: `admin123` + - The hash in .env corresponds to this password + +## Verification + +Run the verification script: +```bash +./scripts/verify-env-fix.sh +``` + +This script will: +- Rebuild containers +- Check environment variables are properly loaded +- Test authentication API +- Show if login is working + +## Testing Login + +1. Access the WebUI at http://localhost:7511 +2. Use password: `admin123` +3. You should be able to log in successfully + +## Troubleshooting + +If issues persist: +1. Check that .env file exists and has proper quotes around values with special characters +2. Ensure Docker containers were rebuilt: `docker compose -f docker-compose.dev.yml up -d --build` +3. Check logs: `docker logs minio-webui-backend-dev` +4. Run debug script: `./scripts/debug-auth.sh` \ No newline at end of file diff --git a/scripts/verify-env-fix.sh b/scripts/verify-env-fix.sh new file mode 100755 index 0000000..7d777a5 --- /dev/null +++ b/scripts/verify-env-fix.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +echo "========================================" +echo "MinIO WebUI - Environment Variable Fix Verification" +echo "========================================" +echo "" + +# Stop existing containers +echo "1. Stopping existing containers..." +docker compose -f docker-compose.dev.yml down + +echo "" +echo "2. Rebuilding and starting containers..." +docker compose -f docker-compose.dev.yml up -d --build + +# Wait for container to start +echo "" +echo "3. Waiting for containers to start..." +sleep 5 + +# Check environment variables +echo "" +echo "4. Checking environment variables in container:" +echo "-----------------------------------------------" +docker exec minio-webui-backend-dev sh -c 'echo "ADMIN_PASSWORD_HASH length: ${#ADMIN_PASSWORD_HASH}"' +docker exec minio-webui-backend-dev sh -c 'echo "ADMIN_PASSWORD_HASH prefix: ${ADMIN_PASSWORD_HASH:0:7}"' +docker exec minio-webui-backend-dev sh -c 'echo "JWT_SECRET length: ${#JWT_SECRET}"' +docker exec minio-webui-backend-dev sh -c 'echo "ALLOWED_IPS: $ALLOWED_IPS"' + +# Run debug script +echo "" +echo "5. Running auth debug:" +echo "---------------------" +./scripts/debug-auth.sh + +# Test API +echo "" +echo "6. Testing API directly:" +echo "-----------------------" +./scripts/test-auth-api.sh + +echo "" +echo "========================================" +echo "Check the outputs above. The password hash should be 60 characters long" +echo "and start with '$2b$12$'. If successful, you should be able to log in" +echo "with password 'admin123'." +echo "========================================" \ No newline at end of file