Production-ready OIDC authentication middleware. Drop-in replacement for oauth2-proxy and forward-auth with support for 9+ identity providers.
Enterprise-grade authentication for your Traefik deployments
Works with Google, Azure AD, Auth0, Okta, Keycloak, Cognito, GitLab, and any OIDC-compliant provider
Automatically detects and configures provider-specific settings from OIDC discovery
RFC 7591 Dynamic Client Registration for automatic client setup without manual configuration
Intelligently filters OAuth scopes based on provider capabilities from discovery documents
Comprehensive security headers including CORS, CSP, HSTS, and customizable profiles
Limit access to specific email domains, individual users, or role-based groups
Restrict access based on roles and groups from OIDC claims
Secure session handling with proactive token refresh before expiry
Built-in protection against brute force attacks with configurable limits
Template-based headers using OIDC claims and tokens for downstream services
Proof Key for Code Exchange for enhanced security in authorization code flow
Bounded caches with LRU eviction, automatic cleanup, and zero goroutine leaks
Works with all major identity providers out of the box
Full OIDC
Full OIDC
Full OIDC
Full OIDC
Full OIDC
Full OIDC
Full OIDC
OAuth 2.0
| Feature | Azure AD | Auth0 | Okta | Keycloak | |
|---|---|---|---|---|---|
| ID Tokens | ✓ | ✓ | ✓ | ✓ | ✓ |
| Refresh Tokens | ✓ | ✓ | ✓ | ✓ | ✓ |
| Auto-Configuration | ✓ | ✓ | ✓ | ✓ | ✓ |
| Custom Claims | Limited | ✓ | ✓ | ✓ | ✓ |
| Group/Role Claims | Limited | ✓ | ✓ | ✓ | ✓ |
| Self-Hosted | ✗ | ✗ | ✗ | ✗ | ✓ |
Get started in under 5 minutes
Add to your Traefik static configuration:
# traefik.yml
experimental:
plugins:
traefikoidc:
moduleName: github.com/lukaszraczylo/traefikoidc
version: v0.7.10
Create your middleware configuration:
# dynamic/middleware.yml
http:
middlewares:
oidc-auth:
plugin:
traefikoidc:
providerURL: "https://accounts.google.com"
clientID: "your-client-id"
clientSecret: "your-client-secret"
callbackURL: "/oauth2/callback"
sessionEncryptionKey: "your-32-byte-secret-key-here!!"
scopes:
- "openid"
- "profile"
- "email"
Use the middleware on your services:
# dynamic/routers.yml
http:
routers:
my-secure-app:
rule: "Host(`app.example.com`)"
service: my-service
middlewares:
- oidc-auth
tls:
certResolver: letsencrypt
Flexible options for any deployment scenario
| Parameter | Description |
|---|---|
providerURL |
Base URL of your OIDC provider |
clientID |
OAuth 2.0 client identifier |
clientSecret |
OAuth 2.0 client secret |
sessionEncryptionKey |
32+ byte key for session encryption |
callbackURL |
OAuth callback path (e.g., /oauth2/callback) |
| Parameter | Default | Description |
|---|---|---|
forceHTTPS |
false | Required for TLS termination at load balancer |
allowedUserDomains |
none | Restrict to specific email domains |
allowedRolesAndGroups |
none | Restrict to users with specific roles |
excludedURLs |
none | Paths that bypass authentication |
enablePKCE |
false | Enable PKCE for enhanced security |
rateLimit |
100 | Maximum requests per second |
http:
middlewares:
google-oidc:
plugin:
traefikoidc:
providerURL: "https://accounts.google.com"
clientID: "1234567890.apps.googleusercontent.com"
clientSecret: "your-client-secret"
callbackURL: "/oauth2/callback"
sessionEncryptionKey: "your-32-byte-encryption-key!!"
allowedUserDomains:
- "yourcompany.com"
- "subsidiary.com"
excludedURLs:
- "/health"
- "/metrics"
- "/api/public"
forceHTTPS: true
logLevel: "info"
Built with enterprise security requirements in mind
A better alternative to oauth2-proxy and forward-auth
| Feature | Traefik OIDC | oauth2-proxy | forward-auth |
|---|---|---|---|
| Native Plugin | ✓ | ✗ | ✗ |
| No Extra Service | ✓ | ✗ | ✗ |
| Auto Provider Detection | ✓ | ✗ | ✗ |
| Dynamic Client Registration | ✓ | ✗ | ✗ |
| Automatic Scope Filtering | ✓ | ✗ | ✗ |
| Built-in Security Headers | ✓ | ✗ | ✗ |
| Template Headers | ✓ | ✓ | ✓ |
| Memory Efficient | ✓ LRU caches | Varies | Varies |
Get started with Traefik OIDC in minutes. Full documentation and examples available on GitHub.