Documentation of security features and authentication options.
For production environments, it is strongly recommended to enable login requirement:
SECURITY_ENABLE_LOGIN=trueSECURITY_INITIAL_LOGIN_USERNAME=admin
SECURITY_INITIAL_LOGIN_PASSWORD= # Leave empty, generated by generate-secrets.shThe initial password is only used on first startup. After that you can:
- Change the password in the web interface
- Create additional users
# With tools container
./tools/run.sh -s './scripts/generate-secrets.sh'
# Directly
./scripts/generate-secrets.shThe script generates:
SECURITY_INITIAL_LOGIN_PASSWORD: Secure admin password- Optional API key
# all: Username/password + OAuth
# normal: Username/password only
# oauth2: OAuth only (after initial setup)
SECURITY_LOGIN_METHOD=allProtection against brute-force attacks:
# Maximum login attempts (-1 = disabled, use fail2ban)
SECURITY_LOGIN_ATTEMPT_COUNT=5
# Lockout duration in minutes
SECURITY_LOGIN_RESET_TIME_MINUTES=120# NEVER disable in production!
SECURITY_CSRF_DISABLED=falseSECURITY_ENABLE_LOGIN=truemust be active- OAuth provider must be configured
SECURITY_OAUTH2_ENABLED=true
SECURITY_OAUTH2_PROVIDER=keycloak # google, github, keycloak, authentikSECURITY_OAUTH2_ISSUER=https://your-idp.com/realms/your-realm
SECURITY_OAUTH2_CLIENT_ID=stirling-pdf
SECURITY_OAUTH2_CLIENT_SECRET=your-client-secret
SECURITY_OAUTH2_SCOPES=openid, profile, email
SECURITY_OAUTH2_USE_AS_USERNAME=preferred_username# Automatically create users on first OAuth login
SECURITY_OAUTH2_AUTO_CREATE_USER=trueSECURITY_OAUTH2_PROVIDER=google
SECURITY_OAUTH2_CLIENT_ID=your-google-client-id
SECURITY_OAUTH2_CLIENT_SECRET=your-google-client-secretSECURITY_OAUTH2_PROVIDER=github
SECURITY_OAUTH2_CLIENT_ID=your-github-client-id
SECURITY_OAUTH2_CLIENT_SECRET=your-github-client-secretSECURITY_CUSTOM_GLOBAL_API_KEY=your-secure-api-keyUsage:
curl -H "X-Api-Key: your-secure-api-key" \
https://pdf.app.bauer-group.com/api/v1/info/statusEach user can create their own API key in the web interface:
- Login to web interface
- Open account settings
- Generate API key
For additional protection, fail2ban can be configured:
# /etc/fail2ban/filter.d/stirling-pdf.conf
[Definition]
failregex = ^.*Invalid username or password.*client: <HOST>.*$
ignoreregex =# /etc/fail2ban/jail.d/stirling-pdf.conf
[stirling-pdf]
enabled = true
filter = stirling-pdf
logpath = /var/log/stirling-pdf/invalid-auths.log
maxretry = 5
bantime = 3600volumes:
- '/var/log/stirling-pdf:/logs'- Enable login:
SECURITY_ENABLE_LOGIN=true - Keep CSRF enabled:
SECURITY_CSRF_DISABLED=false - Use HTTPS: Always via reverse proxy with TLS
- Strong passwords: Use
generate-secrets.sh - Rate limiting: Enable or use fail2ban
- Updates: Update regularly
- Only via reverse proxy: Don't expose port 8080 directly
- Internal network: Container only in internal network
- Firewall: Only open 80/443
security_opt:
- no-new-privileges:true
read_only: true # Where possible# Session timeout (e.g., 30m, 1h)
SERVER_SESSION_TIMEOUT=30m# For security debugging
LOGGING_LEVEL=DEBUG
# Debug OAuth issues
LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_SECURITY_OAUTH2=DEBUG| File | Content |
|---|---|
/logs/stirling-pdf.log |
General logs |
/logs/invalid-auths.log |
Failed login attempts |