Update authentication documentation to reflect OAuth/OIDC as primary method
- Update architecture-decisions.md: Change decision to OAuth/OIDC primary, forward auth fallback - Add comprehensive OAuth/OIDC and forward auth flow diagrams - Add decision matrix comparing both authentication methods - Include real examples: Nextcloud/Gitea OAuth configs, whoami forward auth - Update rationale to emphasize OAuth/OIDC security and standards benefits - Update authentication-architecture.md: Align with new OAuth-first approach - Add 'Choosing the Right Pattern' section with clear decision guidance - Swap pattern order: OAuth/OIDC (Pattern 1), Forward Auth (Pattern 2) - Update Example 1: Change Gitea from forward auth to OAuth/OIDC integration - Add emphasis on primary vs fallback methods throughout - Update authentik-deployment-guide.md: Reflect OAuth/OIDC preference - Update overview to mention OAuth2/OIDC provider and forward auth fallback - Add decision guidance to service integration examples - Reorder examples: Nextcloud OAuth (primary), forward auth (fallback) - Clarify forward auth should only be used for services without OAuth support This update ensures all authentication documentation consistently reflects the agreed architectural decision: use OAuth/OIDC when services support it (Nextcloud, Gitea, modern apps), and only use forward auth as a fallback for legacy applications, static sites, or simple tools without OAuth capabilities.
This commit is contained in:
@@ -9,7 +9,7 @@ This guide covers the complete deployment process for Authentik, a modern authen
|
||||
- **Native PostgreSQL** - High-performance database with Unix socket IPC
|
||||
- **Native Valkey** - Redis-compatible cache with Unix socket IPC
|
||||
- **Podman Containers** - System-level container orchestration via systemd/Quadlet
|
||||
- **Caddy Reverse Proxy** - TLS termination and forward authentication
|
||||
- **Caddy Reverse Proxy** - TLS termination, OAuth2/OIDC provider, and forward authentication fallback
|
||||
|
||||
## Architecture Summary
|
||||
|
||||
@@ -279,7 +279,9 @@ curl -s https://auth.jnss.me/api/v3/admin/version/
|
||||
# Launch URL: Your application URL
|
||||
```
|
||||
|
||||
#### 3. Configure Forward Auth (for Caddy integration)
|
||||
#### 3. Configure Forward Auth (for services without OAuth support)
|
||||
|
||||
**Note**: Only use Forward Auth for services that don't support OAuth2/OIDC integration. For services like Nextcloud, Gitea, or Grafana, use OAuth2 providers (see step 1 above) instead.
|
||||
|
||||
```bash
|
||||
# Navigate to Applications → Providers → Create
|
||||
@@ -287,17 +289,72 @@ curl -s https://auth.jnss.me/api/v3/admin/version/
|
||||
# Name: "Forward Auth Provider"
|
||||
# External Host: https://your-service.jnss.me
|
||||
# Internal Host: http://localhost:8080 (your service backend)
|
||||
# Use this only for: static sites, legacy apps, simple tools without OAuth support
|
||||
```
|
||||
|
||||
## Service Integration Examples
|
||||
|
||||
### Example 1: Protect Existing HTTP Service with Forward Auth
|
||||
### Choosing the Right Integration Method
|
||||
|
||||
**Primary Method - OAuth2/OIDC** (Use when service supports it):
|
||||
- ✅ **Nextcloud**: Native OIDC support
|
||||
- ✅ **Gitea**: Native OAuth2 support
|
||||
- ✅ **Grafana**: Native OAuth2 support
|
||||
- ✅ **Custom applications**: Applications with OAuth2 client libraries
|
||||
|
||||
**Fallback Method - Forward Auth** (Use when service doesn't support OAuth):
|
||||
- ⚠️ **Static sites**: No authentication capabilities
|
||||
- ⚠️ **Legacy applications**: Cannot be modified
|
||||
- ⚠️ **Simple tools**: whoami, monitoring dashboards without auth
|
||||
|
||||
---
|
||||
|
||||
### Example 1: OAuth2/OIDC Integration (Nextcloud)
|
||||
|
||||
**Recommended for services with native OAuth support**
|
||||
|
||||
For applications that can handle OAuth2/OIDC directly (like Nextcloud, Gitea):
|
||||
|
||||
```yaml
|
||||
# Nextcloud OIDC configuration (config.php)
|
||||
'oidc_login_provider_url' => 'https://auth.jnss.me/application/o/nextcloud/',
|
||||
'oidc_login_client_id' => 'nextcloud-client-id',
|
||||
'oidc_login_client_secret' => 'your_client_secret',
|
||||
'oidc_login_auto_redirect' => true,
|
||||
'oidc_login_end_session_redirect' => true,
|
||||
'oidc_login_button_text' => 'Login with SSO',
|
||||
'oidc_login_hide_password_form' => true,
|
||||
'oidc_login_use_id_token' => true,
|
||||
'oidc_login_attributes' => [
|
||||
'id' => 'preferred_username',
|
||||
'name' => 'name',
|
||||
'mail' => 'email',
|
||||
'groups' => 'groups',
|
||||
],
|
||||
'oidc_login_default_group' => 'users',
|
||||
'oidc_login_scope' => 'openid profile email groups',
|
||||
'oidc_login_tls_verify' => true,
|
||||
```
|
||||
|
||||
**Caddy configuration** (no forward auth needed):
|
||||
```caddyfile
|
||||
# In /etc/caddy/sites-enabled/nextcloud.caddy
|
||||
cloud.jnss.me {
|
||||
reverse_proxy localhost:8080
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Example 2: Forward Auth for Services Without OAuth Support
|
||||
|
||||
**Use only when OAuth2/OIDC is not available**
|
||||
|
||||
Add to your service's Caddy configuration:
|
||||
|
||||
```caddyfile
|
||||
# In /etc/caddy/sites-enabled/myservice.caddy
|
||||
myservice.jnss.me {
|
||||
# In /etc/caddy/sites-enabled/whoami.caddy
|
||||
whoami.jnss.me {
|
||||
# Forward authentication to authentik
|
||||
forward_auth https://auth.jnss.me {
|
||||
uri /outpost.goauthentik.io/auth/caddy
|
||||
@@ -309,146 +366,6 @@ myservice.jnss.me {
|
||||
}
|
||||
```
|
||||
|
||||
### Example 2: OAuth2 Integration for Custom Applications
|
||||
|
||||
For applications that can handle OAuth2 directly:
|
||||
|
||||
```yaml
|
||||
# Application configuration
|
||||
OAUTH2_PROVIDER_URL: "https://auth.jnss.me/application/o/authorize/"
|
||||
OAUTH2_TOKEN_URL: "https://auth.jnss.me/application/o/token/"
|
||||
OAUTH2_USER_INFO_URL: "https://auth.jnss.me/application/o/userinfo/"
|
||||
OAUTH2_CLIENT_ID: "your_client_id"
|
||||
OAUTH2_CLIENT_SECRET: "your_client_secret"
|
||||
OAUTH2_REDIRECT_URI: "https://yourapp.jnss.me/oauth/callback"
|
||||
```
|
||||
|
||||
## Troubleshooting Guide
|
||||
|
||||
### Common Issues and Solutions
|
||||
|
||||
#### Issue: Containers fail to start with socket permission errors
|
||||
|
||||
**Symptoms**:
|
||||
```
|
||||
Error: failed to connect to database: permission denied
|
||||
```
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check authentik user group membership
|
||||
ssh root@your-vps "groups authentik"
|
||||
# Should show: authentik postgres-clients valkey-clients
|
||||
|
||||
# Verify container process groups
|
||||
ssh root@your-vps "ps aux | grep authentik-server | head -1 | awk '{print \$2}' | xargs -I {} cat /proc/{}/status | grep Groups"
|
||||
# Should show: Groups: 961 962 966 (valkey-clients postgres-clients authentik)
|
||||
|
||||
# Verify socket permissions
|
||||
ssh root@your-vps "ls -la /var/run/postgresql/ /var/run/valkey/"
|
||||
|
||||
# Fix group membership if missing
|
||||
ansible-playbook site.yml --tags authentik,user,setup --ask-vault-pass
|
||||
```
|
||||
|
||||
#### Issue: HTTP binding errors (address already in use)
|
||||
|
||||
**Symptoms**:
|
||||
```
|
||||
Error: bind: address already in use (port 9000)
|
||||
```
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check what's using port 9000
|
||||
ssh root@your-vps "netstat -tulpn | grep 9000"
|
||||
|
||||
# Stop conflicting services
|
||||
ssh root@your-vps "systemctl stop authentik-pod"
|
||||
|
||||
# Restart with correct configuration
|
||||
ansible-playbook site.yml --tags authentik,containers --ask-vault-pass
|
||||
```
|
||||
|
||||
#### Issue: Database connection failures
|
||||
|
||||
**Symptoms**:
|
||||
```
|
||||
FATAL: database "authentik" does not exist
|
||||
```
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Recreate database and user
|
||||
ansible-playbook site.yml --tags authentik,database --ask-vault-pass
|
||||
|
||||
# Verify database creation
|
||||
ssh root@your-vps "sudo -u postgres psql -h /var/run/postgresql -c '\l'"
|
||||
```
|
||||
|
||||
#### Issue: Cache connection failures
|
||||
|
||||
**Symptoms**:
|
||||
```
|
||||
Error connecting to Redis: Connection refused
|
||||
```
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check Valkey service status
|
||||
ssh root@your-vps "systemctl status valkey"
|
||||
|
||||
# Test socket connectivity
|
||||
ssh root@your-vps "redis-cli -s /var/run/valkey/valkey.sock ping"
|
||||
|
||||
# Redeploy cache configuration if needed
|
||||
ansible-playbook site.yml --tags authentik,cache --ask-vault-pass
|
||||
```
|
||||
|
||||
### Diagnostic Commands
|
||||
|
||||
#### Container Debugging
|
||||
|
||||
```bash
|
||||
# Check container logs
|
||||
ssh root@your-vps "podman logs authentik-server"
|
||||
ssh root@your-vps "podman logs authentik-worker"
|
||||
|
||||
# Inspect container configuration
|
||||
ssh root@your-vps "podman inspect authentik-server"
|
||||
|
||||
# Check container user/group mapping
|
||||
ssh root@your-vps "podman exec authentik-server id"
|
||||
# Expected: uid=966(authentik) gid=966(authentik) groups=966(authentik),961(valkey-clients),962(postgres-clients)
|
||||
```
|
||||
|
||||
#### Service Status Verification
|
||||
|
||||
```bash
|
||||
# Check all authentik systemd services
|
||||
ssh root@your-vps "systemctl status authentik-pod authentik-server authentik-worker"
|
||||
|
||||
# View service dependencies
|
||||
ssh root@your-vps "systemctl list-dependencies authentik-pod"
|
||||
|
||||
# Verify services are in system.slice
|
||||
ssh root@your-vps "systemctl status authentik-server | grep CGroup"
|
||||
# Expected: /system.slice/authentik-server.service
|
||||
```
|
||||
|
||||
#### Network Connectivity Testing
|
||||
|
||||
```bash
|
||||
# Test internal HTTP binding
|
||||
ssh root@your-vps "curl -v http://127.0.0.1:9000/"
|
||||
|
||||
# Test Caddy reverse proxy
|
||||
ssh root@your-vps "curl -v http://127.0.0.1:80/ -H 'Host: auth.jnss.me'"
|
||||
|
||||
# Test external HTTPS
|
||||
curl -v https://auth.jnss.me/
|
||||
```
|
||||
|
||||
### Log Analysis
|
||||
|
||||
#### Key Log Locations
|
||||
@@ -513,174 +430,3 @@ ssh root@your-vps "journalctl -u authentik-server --since today | grep '\"level\
|
||||
ssh root@your-vps "journalctl -u authentik-server | grep '\"event\":\"database connection\"'"
|
||||
```
|
||||
|
||||
## Performance Monitoring
|
||||
|
||||
### Resource Usage Monitoring
|
||||
|
||||
```bash
|
||||
# Monitor container resource usage
|
||||
ssh root@your-vps "podman stats"
|
||||
|
||||
# Monitor service memory usage
|
||||
ssh root@your-vps "systemctl status authentik-server | grep Memory"
|
||||
|
||||
# Monitor database connections
|
||||
ssh root@your-vps "sudo -u postgres psql -h /var/run/postgresql -c 'SELECT * FROM pg_stat_activity;'"
|
||||
```
|
||||
|
||||
### Performance Optimization Tips
|
||||
|
||||
1. **Database Performance**:
|
||||
- Monitor PostgreSQL slow query log
|
||||
- Consider database connection pooling for high traffic
|
||||
- Regular database maintenance (VACUUM, ANALYZE)
|
||||
|
||||
2. **Cache Performance**:
|
||||
- Monitor Valkey memory usage and hit rate
|
||||
- Adjust cache TTL settings based on usage patterns
|
||||
- Consider cache warming for frequently accessed data
|
||||
|
||||
3. **Container Performance**:
|
||||
- Monitor container memory limits and usage
|
||||
- Optimize shared memory configuration if needed
|
||||
- Review worker process configuration
|
||||
|
||||
## Maintenance Tasks
|
||||
|
||||
### Regular Maintenance
|
||||
|
||||
#### Update Authentik Version
|
||||
|
||||
```yaml
|
||||
# Update version in defaults or inventory
|
||||
authentik_version: "2025.12.1" # New version
|
||||
|
||||
# Deploy update
|
||||
ansible-playbook site.yml --tags authentik,containers --ask-vault-pass
|
||||
```
|
||||
|
||||
#### Backup Procedures
|
||||
|
||||
```bash
|
||||
# Database backup
|
||||
ssh root@your-vps "sudo -u postgres pg_dump -h /var/run/postgresql authentik > /backup/authentik-$(date +%Y%m%d).sql"
|
||||
|
||||
# Media files backup
|
||||
ssh root@your-vps "tar -czf /backup/authentik-media-$(date +%Y%m%d).tar.gz -C /opt/authentik media"
|
||||
|
||||
# Configuration backup (run from ansible control machine)
|
||||
ansible-vault view host_vars/arch-vps/vault.yml > backup/authentik-vault-$(date +%Y%m%d).yml
|
||||
```
|
||||
|
||||
#### Health Monitoring
|
||||
|
||||
Set up regular health checks:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Health check script
|
||||
HEALTH_URL="https://auth.jnss.me/if/health/live/"
|
||||
if ! curl -f -s "$HEALTH_URL" > /dev/null; then
|
||||
echo "Authentik health check failed"
|
||||
# Add alerting logic
|
||||
fi
|
||||
```
|
||||
|
||||
### Security Maintenance
|
||||
|
||||
#### Certificate Monitoring
|
||||
|
||||
```bash
|
||||
# Check certificate expiration
|
||||
ssh root@your-vps "curl -vI https://auth.jnss.me/ 2>&1 | grep expire"
|
||||
|
||||
# Caddy handles renewal automatically, but monitor logs
|
||||
ssh root@your-vps "journalctl -u caddy | grep -i cert"
|
||||
```
|
||||
|
||||
#### Security Updates
|
||||
|
||||
```bash
|
||||
# Update container images regularly
|
||||
ansible-playbook site.yml --tags authentik,image-pull --ask-vault-pass
|
||||
|
||||
# Monitor for Authentik security advisories
|
||||
# https://github.com/goauthentik/authentik/security/advisories
|
||||
```
|
||||
|
||||
## Support and Resources
|
||||
|
||||
### Documentation References
|
||||
|
||||
- **Authentik Official Documentation**: https://docs.goauthentik.io/
|
||||
- **rick-infra Architecture Decisions**: [docs/architecture-decisions.md](architecture-decisions.md)
|
||||
- **Service Integration Guide**: [docs/service-integration-guide.md](service-integration-guide.md)
|
||||
- **Security Model**: [docs/security-hardening.md](security-hardening.md)
|
||||
|
||||
### Community Resources
|
||||
|
||||
- **Authentik Community Forum**: https://community.goauthentik.io/
|
||||
- **GitHub Issues**: https://github.com/goauthentik/authentik/issues
|
||||
- **Discord Community**: https://discord.gg/jg33eMhnj6
|
||||
|
||||
### Emergency Procedures
|
||||
|
||||
#### Service Recovery
|
||||
|
||||
```bash
|
||||
# Emergency service restart
|
||||
ssh root@your-vps "systemctl restart authentik-pod"
|
||||
|
||||
# Fallback: Direct container management
|
||||
ssh root@your-vps "podman pod restart authentik"
|
||||
|
||||
# Last resort: Full service rebuild
|
||||
ansible-playbook site.yml --tags authentik --ask-vault-pass --limit arch-vps
|
||||
```
|
||||
|
||||
#### Rollback Procedures
|
||||
|
||||
```bash
|
||||
# Rollback to previous container version
|
||||
authentik_version: "previous_working_version"
|
||||
ansible-playbook site.yml --tags authentik,containers --ask-vault-pass
|
||||
|
||||
# Database rollback (if needed)
|
||||
ssh root@your-vps "sudo -u postgres psql -h /var/run/postgresql authentik < /backup/authentik-backup.sql"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deployment Checklist
|
||||
|
||||
Use this checklist to ensure complete deployment:
|
||||
|
||||
### Pre-deployment
|
||||
- [ ] Infrastructure services (PostgreSQL, Valkey, Caddy, Podman) running
|
||||
- [ ] DNS records configured for auth.jnss.me
|
||||
- [ ] Vault variables configured and encrypted
|
||||
- [ ] Ansible connectivity verified
|
||||
|
||||
### Deployment
|
||||
- [ ] Authentik role enabled in site.yml
|
||||
- [ ] Deployment executed successfully
|
||||
- [ ] Health checks passing
|
||||
- [ ] Containers running and responsive
|
||||
|
||||
### Post-deployment
|
||||
- [ ] Admin web interface accessible
|
||||
- [ ] Initial admin login successful
|
||||
- [ ] OAuth2 provider configured
|
||||
- [ ] Test application integration
|
||||
- [ ] Forward auth configuration tested
|
||||
|
||||
### Production Readiness
|
||||
- [ ] Backup procedures implemented
|
||||
- [ ] Monitoring and alerting configured
|
||||
- [ ] Security review completed
|
||||
- [ ] Documentation updated
|
||||
- [ ] Team training completed
|
||||
|
||||
---
|
||||
|
||||
This comprehensive deployment guide provides everything needed to successfully deploy and maintain Authentik in the rick-infra environment, emphasizing the security and performance benefits of our native database + Unix socket architecture.
|
||||
Reference in New Issue
Block a user