Deploy Authentik with OpenID Connect for Centralized Security in Coolify
This guide provides a detailed walkthrough for deploying Authentik as a centralized security solution integrated with Coolify via OpenID Connect (OIDC). It enables unified...
Image credit: niekverlaan · Pixabay Content License
This guide provides a detailed walkthrough for deploying Authentik as a centralized security solution integrated with Coolify via OpenID Connect (OIDC). It enables unified authentication, enhanced security, and simplified user management in automated application environments. Authentik acts as an Identity Provider (IdP) supporting OIDC, securing Coolify’s dashboard, APIs, and other services by centralizing login processes. The guide covers setup, configuration, testing, and verification, assuming basic knowledge of Docker, Kubernetes, and security protocols.
Overview of Authentik and OpenID Connect
Authentik is an open-source Identity and Access Management (IAM) platform supporting multiple authentication protocols, including OpenID Connect (OIDC), SAML, and OAuth2. In this context, Authentik functions as an Identity Provider (IdP), authenticating users for applications like Coolify. OpenID Connect (OIDC), built on OAuth2, allows secure user authentication through a trusted intermediary, eliminating the need for each application to manage user credentials independently. When users log in to Coolify, they are redirected to Authentik for authentication, receiving an ID token to access the service. This approach reduces security risks, avoids credential duplication, and streamlines access control.
Prerequisites and Environment Setup
To deploy Authentik with Coolify, ensure the following prerequisites are met:
- Run Authentik on a server or Kubernetes cluster, such as a Cloud VPS with L3/L4/L7 Anycast Anti-DDoS protection at DPTCloud.
- Ensure stable internet connectivity and external accessibility if required.
- Install Docker and Docker Compose (or Kubernetes for containerized environments).
- Have a valid domain (e.g., authentik.example.com) and SSL certificate (Let's Encrypt recommended).
- Have Coolify deployed and access to its admin interface.
Before starting, verify that the system has sufficient resources (CPU, RAM, disk space) to run Authentik and its dependencies. A reliable infrastructure like the Network Security & 99.98% SLA Infrastructure at DPTCloud ensures deployment stability.
Deploy Authentik Using Docker
Deploy Authentik using Docker Compose. Create a `docker-compose.yml` file with the following content:
version: '3.8'\n\nservices:\n authentik:\n image: goauthentik/authentik:latest\n container_name: authentik\n ports:\n - \"443:443\"\n volumes:\n - ./data:/opt/authentik/data\n environment:\n - AUTHENTIK_SECRET_KEY=your-secret-key-here\n - AUTHENTIK_DATABASE_URL=postgres://authentik:password@postgres:5432/authentik\n - AUTHENTIK_REDIS_URL=redis://redis:6379\n depends_on:\n - postgres\n - redis\n restart: unless-stopped\n\n postgres:\n image: postgres:15\n container_name: authentik_postgres\n volumes:\n - ./postgres_data:/var/lib/postgresql/data\n environment:\n - POSTGRES_DB=authentik\n - POSTGRES_USER=authentik\n - POSTGRES_PASSWORD=password\n restart: unless-stopped\n\n redis:\n image: redis:7\n container_name: authentik_redis\n restart: unless-stoppedRun the following command to start the services:
docker-compose up -dAfter startup, access the Authentik admin interface via a browser at `https://authentik.example.com`. Configure basic settings, such as creating users, groups, and security policies. Then, create a new OIDC application and assign a name and valid callback URL.
Connect Coolify to Authentik via OIDC
In Coolify, navigate to Security Settings and select OpenID Connect as the authentication method. Enter the following details:
- Client ID: The value generated when creating the OIDC application in Authentik.
- Client Secret: The secret associated with the OIDC application.
- Issuer URL: Authentik’s URL (e.g., https://authentik.example.com/api/v1/providers/oidc/).
- Redirect URI: The URL where Coolify receives the token after successful authentication.
After configuration, save and test login into Coolify. Users will be redirected to Authentik for authentication. Upon success, they will return to Coolify with authenticated access.
Verification and Testing
To verify the deployment, follow these steps:
- Access the Coolify interface and click the login button.
- Users should be redirected to the Authentik login page.
- Log in using a user account created in Authentik.
- Return to Coolify and confirm successful authentication.
If issues occur, check Authentik and Coolify logs for errors. Common problems include incorrect URLs, mismatched Client ID/Secret, or invalid SSL certificates. Ensure both Authentik and Coolify use valid, trusted SSL certificates.
Advanced Security Measures
Enhance security by implementing the following:
- Enable two-factor authentication (2FA) in Authentik for all users.
- Configure security policies such as token expiration and failed login limits.
- Integrate with an agentless HIDS system using SSH log parsing and Grafana Loki to monitor suspicious login activity.
- Perform regular Authentik data backups using a solution like Kopia with high-security SFTP connection.
Troubleshooting
If connectivity fails, verify the following:
- Authentik is running and accessible externally.
- The OIDC application in Authentik is correctly created and configured.
- Coolify’s OIDC settings (Client ID, Client Secret, Issuer URL) are accurate.
- SSL certificates on Authentik are valid and trusted by browsers.
- Check Authentik and Coolify logs for detailed error messages.
References
For more information on Authentik and OpenID Connect, refer to the official documentation at https://goauthentik.io. Detailed deployment guides are available in the Authentik and Coolify documentation. Additional security insights can be found in articles such as Comprehensive VPS Security: Deploying SSH3 Protocol Based on HTTP3 QUIC to Eliminate Port Scanning Risks and Comprehensive Container Security: Using eBPF Tetragon to Monitor and Block Unauthorized System File Writes.
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
