Welcome to homelab-auth
First, you need to ensure you have brew, task, docker, git, and uv installed locally, and the docker daemon is running.
Then, you can setup your local environment via:
# Install the dependencies
task init
# Build the image
task build
# Run the image
docker run --rm -ti -p 55001:55000 MrSecure/homelab-auth:latestIf you'd like to build all of the supported docker images, you can set the PLATFORM env var to all like this:
PLATFORM=all task buildYou can also specify a single platform of either linux/arm64 or linux/amd64
For local development, you can run the service directly with:
task runThis starts the Flask development server on http://127.0.0.1:55000.
This project includes a dedicated WSGI entrypoint for running under production WSGI servers such as gunicorn.
Run the application locally with gunicorn using the task runner:
task run-gunicornThis is equivalent to:
HOMELAB_AUTH_CONFIG_FILE=support/wsgi-config.yaml \
HOMELAB_AUTH_HASHING_KEY="homelab-auth-dev-key" \
gunicorn --bind 0.0.0.0:8000 --workers 4 --timeout 120 \
--access-logfile - --error-logfile - src.wsgi:app- Entry module: src/wsgi.py — exports the Flask application as
appfor WSGI servers. - Behavior: The WSGI module prepares a controlled
sys.argvso the application initializes from environment variables instead of arbitrary CLI args. It also applies a compatibility fix for newerbcrypt/passlibversions used at startup. - Key feature: Environment variable-driven configuration allows for zero-CLI-args deployment in containerized environments.
The WSGI entrypoint accepts the following environment variables:
| Variable | Default | Purpose |
|---|---|---|
HOMELAB_AUTH_CONFIG_FILE |
config.yaml |
Path to the configuration file |
HOMELAB_AUTH_HASHING_KEY |
(auto-generated) | Session signing key (highest precedence) |
The application supports three methods for providing the hashing key (in order of precedence):
- Environment Variable (for WSGI deployment):
export HOMELAB_AUTH_HASHING_KEY="your-secret-key"
gunicorn -w 4 -b 0.0.0.0:55000 src.wsgi:app- CLI Argument (for direct Python execution):
python src/main.py config.yaml --hashing-key "your-secret-key"- Auto-generated Fallback: If neither option is provided, the application generates a SHA1 hash of the configuration file. This is useful for development but should not be used in production where stability across deployments is required.
# Using gunicorn directly
HOMELAB_AUTH_CONFIG_FILE=/path/to/config.yaml \
HOMELAB_AUTH_HASHING_KEY="your-stable-production-key" \
gunicorn \
--workers 4 \
--worker-class sync \
--bind 0.0.0.0:55000 \
--timeout 30 \
--keep-alive 5 \
--max-requests 1000 \
--max-requests-jitter 100 \
--graceful-timeout 10 \
--access-logfile - \
--error-logfile - \
src.wsgi:appThe Docker image includes an optimized entrypoint (support/entrypoint.sh) that runs gunicorn with production-recommended settings. The container:
- Uses gunicorn with 4 workers by default
- Configures proper timeouts for long-running requests
- Maintains connection pooling via
--keep-alive - Recycles workers periodically via
--max-requests - Streams logs to stdout/stderr for container orchestration
See docs/WSGI_DEPLOYMENT.md for detailed WSGI deployment patterns.
For configuration file structure and validation, see docs/WSGI_DEPLOYMENT.md for detailed guidance on config file setup.
If you'd like to be able to run task license-check locally, you will need to install grant and ensure it's in your PATH.
If you're troubleshooting the results of any of the tasks, you can add -v to enable debug task logging, for instance:
task -v build- GET/POST
/logout- Invalidates the user session cookie and logs out the user
This project is configured with automated dependency management:
- Dependabot: Automatically creates pull requests for Python, GitHub Actions, and Docker dependency updates
- Renovate: Provides more advanced dependency update management with grouping and scheduling capabilities
Both tools are pre-configured and will start working once the repository is pushed to GitHub.
For frequently asked questions including release workflow troubleshooting, see our FAQ documentation.
This project was generated with 🤟 by Zenable
Initial htpasswd file created via
htpasswd -nbB randomly-generated "$(openssl rand -base64 78)"