Authentication and Single Sign-On (SSO)#
Overview
This cluster implements a comprehensive authentication architecture with Single Sign-On capabilities using Authelia as the identity provider, LLDAP for user management, and Traefik ForwardAuth middleware to protect all exposed services.
Architecture#
The authentication system consists of four main components working together:
Component Responsibilities#
| Component | Role | Storage Backend | Namespace | 
|---|---|---|---|
| Authelia | Authentication, authorization, session management, OIDC provider | MariaDB (storage), Redis (sessions) | authelia | 
| LLDAP | Lightweight LDAP directory for user/group management | MariaDB | authelia | 
| Redis | Session storage for Authelia | In-memory with optional persistence | databases | 
| MariaDB | Persistent storage for Authelia data and LLDAP users | Persistent volumes | databases | 
| Traefik | ForwardAuth middleware enforcement | N/A | kube-system | 
Deployment Architecture#
Sync Wave Order#
Applications are deployed in a specific order via ArgoCD sync waves to ensure dependencies are met:
-  Wave 09: Redis (Session backend) - Helm chart: bitnami/redis:23.1.1- Deployed to:databasesnamespace - See:apps/argo-cd-apps/09-redis.yaml
-  Wave 10: Authelia (Authentication service) - Helm chart: authelia/authelia:0.10.46- Deployed to:authelianamespace - Replicas: 2 (high availability) - See:apps/argo-cd-apps/10-authelia.yaml
-  Wave 11: LLDAP (User directory) - Custom deployment - Image: ghcr.io/lldap/lldap:latest-alpine- Deployed to:authelianamespace - See:apps/argo-cd-apps/11-lldap.yaml
MariaDB Dependency
MariaDB is deployed earlier in sync wave 08 and must be available before Authelia and LLDAP start. See the Databases documentation for details.
Authelia Configuration#
Authelia is responsible for authentication and authorization.
Authentication Backend: LDAP#
Authelia uses LLDAP as its authentication backend:
Key Points: - Provices encrypted LDAP connection within cluster (cluster-internal communication) - Password reset functionality is enabled - Users are stored under ou=people - Groups are stored under ou=groups - Currently Authelia binds as the LDAP admin user to query directory
Session Management: Redis#
Sessions are stored in Redis for authelia scalability:
Session Behavior: - Sessions expire after 1 hour of total time - Sessions expire after 5 minutes of inactivity - "Remember me" option extends session to 1 month - Sessions are stored in Redis database index 1 (separate from other applications)
Storage Backend: MariaDB#
Authelia stores persistent data in MariaDB:
Stored Data: - User preferences - TOTP secrets for 2FA - U2F device registrations - OAuth2 consent decisions - Identity verification tokens
Access Control Policies#
The default policy is deny with explicit rules granting access:
Policy Explanation: - All access is denied by default - Any subdomain under k8s.example.com and internal.example.com requires two-factor authentication - Additional rules can be added for specific applications or paths
Two-Factor Enforcement
All exposed services require two-factor authentication (TOTP or U2F). Users must configure 2FA before accessing protected resources.
OIDC Provider#
Authelia acts as an OpenID Connect provider for applications that support native OIDC integration:
Some OIDC Clients: - Grafana: Integrated for monitoring dashboard access - Argo CD: Integrated for GitOps management console - Semaphore: Integrated for Ansible playbook automation
Adding OIDC Clients
To add a new OIDC client, generate a client secret using:
apps/authelia/values.enc.yaml. Notification Provider: SMTP#
Authelia sends notifications via SMTP for password resets and identity verification:
Internal SMTP
This configuration uses an SMTP relay outside of the cluster, but from within the home network, without authentication.
Authorization Endpoints#
Authelia exposes multiple authorization endpoints for different middleware types:
- ForwardAuth: Used by Traefik (currently in use)
- AuthRequest: Compatible with NGINX ingress
- ExtAuthz: Compatible with Envoy proxy
LLDAP Configuration#
LLDAP provides a lightweight, opinionated LDAP directory with a web UI.
Deployment#
LLDAP runs as a single replica deployment:
Service Endpoints#
LLDAP exposes two service ports:
- Port 3890: LDAP protocol
- Port 6360: LDAPS protocol
- Port 17170: Web management interface
Web Interface Access#
LLDAP has its own ingress for administrative management:
LLDAP Admin Access
The LLDAP web interface is accessible but does NOT have ForwardAuth middleware applied. It uses its own internal authentication.
User and Group Management#
LLDAP follows a simplified LDAP schema:
- Base DN: DC=example,DC=com
- Users: ou=people,dc=example,dc=com
- Groups: ou=groups,dc=example,dc=com
Adding Users: 1. Access the LLDAP web interface at the configured ingress 2. Navigate to "Users" and click "Create User" 3. Fill in required fields: username, email, display name 4. Set initial password 5. Assign groups as needed
Managing Groups: 1. Navigate to "Groups" in LLDAP UI 2. Create groups to organize users 3. Add users to groups 4. Use groups in Authelia access control policies or OIDC claims
Traefik Integration#
Traefik enforces authentication using the ForwardAuth middleware.
ForwardAuth Middleware#
The Authelia Helm chart automatically creates a ForwardAuth middleware resource:
Middleware Behavior: - Traefik sends request headers to Authelia - Authelia validates authentication and authorization - If authenticated: Request proceeds with identity headers added - If not authenticated: User redirected to Authelia login page
Protecting Services with ForwardAuth#
To protect an application with SSO, add the middleware annotation to its Ingress:
Secret Management#
All sensitive authentication data is encrypted with SOPS.
Encrypted Files#
Authentication secrets are stored in:
- apps/authelia/values.enc.yaml: Authelia secrets (LDAP password, session keys, OIDC secrets)
- apps/lldap/lldap-secret.enc.yaml: LLDAP admin password and JWT secret
- apps/redis/values.enc.yaml: Redis password (if authentication enabled; currently disabled)
Secret Rotation#
Rotating OIDC Client Secrets:
-  Generate new client secret: 
-  Update the application configuration with the new secret 
- Update apps/authelia/values.enc.yamlwith the new hashed secret
- Commit changes and let ArgoCD sync
Rotating Session Encryption Key:
- Generate new random key (64 characters recommended)
- Update session.encryption_key.valuein Authelia configuration
- Commit and sync
- All existing sessions will be invalidated
Session Key Rotation
Rotating the session encryption key will log out all users.
Troubleshooting#
emby ldaps connection#
Emby requires the sha1 fingerprint from the certificate. After a renewal, the sha1 fingerprint changes and emby needs the new one. To get the fingerprint use the following command in a pod within the cluster (e.g. netshoot):
Login Failures#
Symptom: User cannot log in with correct credentials
Diagnosis:
Common Causes: - LDAP bind password incorrect - LLDAP service not running - User doesn't exist in LLDAP - User not in required group
Best Practices#
Security Recommendations#
-  Enforce Two-Factor Authentication - Set policy: two_factorfor all production services - Use hardware security keys (U2F) for administrator accounts - Regularly audit user 2FA enrollment
-  Rotate Secrets Regularly - Rotate OIDC client secrets annually - Rotate session encryption keys during maintenance windows - Use strong random passwords for LDAP bind accounts 
-  Monitor Authentication Logs - Set up alerts for repeated login failures - Monitor Authelia logs for suspicious activity - Track OIDC token issuance 
-  Network Segmentation - Use Cilium network policies to restrict access to authentication components - Only allow necessary egress to Authelia from application pods - Isolate LLDAP to only Authelia access 
-  Backup Critical Data - Include MariaDB autheliadatabase in backup strategy - Backup LLDAP database regularly - Store SOPS encryption keys securely off-cluster
Access Control Design#
-  Use Groups for Authorization - Create LDAP groups for different access levels (admins, users, viewers) - Reference groups in Authelia access control policies - Pass groups as OIDC claims to applications 
-  Granular Policies - Define specific access rules per application - Use domain and path-based rules for fine-grained control - Document policy decisions in comments 
-  Test Access Policies - Test with non-privileged user accounts - Verify group membership affects access - Ensure deny-by-default behavior 
Additional Resources#
- Authelia Documentation
- LLDAP Documentation
- Traefik ForwardAuth Documentation
- Cilium Network Policy Guide
Related Documentation#
- Databases - MariaDB and Redis configuration
- Network - Traefik ingress and network architecture
- Secret Management - SOPS encryption details
- Monitoring - Observability for authentication components