Paperless-ngx OIDC Configuration Guide
Learn how to configure OIDC single sign-on in Paperless-ngx with Authentik or Keycloak. Covers setup, common pitfalls, group sync, and when to use OIDC.
- OIDC centralizes login and group management but requires running an OIDC provider like Authentik or Keycloak, adding operational complexity.
- Configure your OIDC provider with RSA signing keys (not EC), set the redirect URI exactly, and disable encryption in provider settings to avoid common setup failures.
- Paperless-ngx v3.4.0 and later auto-sync users and groups from OIDC, eliminating manual permission assignment.
- OIDC is overkill for single-user setups or small teams under 3 people; it shines for 5+ person teams managing role-based document access.
- If your OIDC provider goes offline, users cannot log in to Paperless after session expiry, so use a hosted provider with uptime SLA for production.
OpenID Connect (OIDC) in Paperless-ngx gives you single sign-on (SSO) through a central identity provider like Authentik or Keycloak. It eliminates separate Paperless passwords and centralizes user and group management. OIDC is powerful for multi-user setups but adds complexity. This guide walks you through setup, troubleshooting, and when to skip it entirely.
What Is OIDC and Should You Use It?
OIDC is an authentication layer built on OAuth 2.0. Instead of storing passwords in Paperless itself, you delegate login to a trusted provider. When users need to access Paperless, they authenticate against that provider, then get a secure token Paperless validates.
The real wins: One password for multiple apps. Central audit trail of who logged in and when. Groups defined in the provider automatically map to Paperless permissions. You can lock down document access by team or department without touching Paperless directly.
The costs: You must run an OIDC provider (Authentik, Keycloak) or subscribe to one (Okta). If that provider goes offline, users cannot log in to Paperless. Configuration is not trivial. Keys must be RSA, not EC. Token endpoints need exact auth method settings. Paperless-ngx version 3.4.0 and later have better support (automated user and group sync added in v3.4.0).
Is OIDC worth it? For a household or solo freelancer: probably not. For a 5-person firm with internal apps, shared documents, and compliance needs: yes. For 10-100 people managing sensitive records: absolutely.
Prerequisites: Choose Your OIDC Provider
You need an OIDC provider running. Here are the tested options:
-
Authentik: Self-hosted, open-source identity provider. Easiest integration with Paperless-ngx (official integration guide exists). Requires a Docker container or systemd service. Free.
-
Keycloak: Enterprise-grade identity platform. More features than Authentik, steeper learning curve. Self-hosted. Free.
-
Okta: SaaS platform. No self-hosting needed, but paid plans start at standard tier. Good for distributed teams.
For this guide, we focus on Authentik because it has the fewest moving parts and an official integration guide.
Before you configure OIDC in Paperless-ngx, have your provider ready. You will need:
- Provider URL: Where OIDC requests will be sent (e.g.,
https://<authentik-domain>/application/o/) - Client ID: A unique string identifying Paperless to your provider
- Client Secret: A password for that client (keep it secret)
- Signing Key: Must be RSA (2048-bit minimum), not EC. This is a common failure point.
Enable OIDC in Paperless-ngx
Paperless-ngx uses django-allauth for social authentication. You enable it via environment variables in your docker-compose.yml or env file.
Add these variables:
PAPERLESS_ENABLE_ALLAUTH=true
PAPERLESS_APPS=allauth.socialaccount
PAPERLESS_SOCIALACCOUNT_PROVIDERS={
"openid_connect": {
"APPS": [
{
"provider_id": "authentik",
"name": "Authentik",
"client_id": "YOUR_CLIENT_ID",
"secret": "YOUR_CLIENT_SECRET",
"settings": {
"server_url": "https://<authentik-domain>/application/o/",
"token_auth_method": "client_secret_post"
}
}
]
}
}
Restart Paperless after updating. Check the login page: you should see an "Authentik" button.
Do not leave token_auth_method as default. Set it explicitly to client_secret_post. This tells Paperless to send the client secret in the request body, not as a header. If you get a 401 error on token exchange, this is the first thing to check.
Configure Authentik as Your OIDC Provider
In Authentik's admin interface, create an OAuth2/OIDC application:
- Go to Applications > Applications.
- Click Create.
- Choose "OpenID Connect" as the provider.
- Set the name to "Paperless-ngx".
- Set the redirect URI exactly as:
https://<paperless-domain>/accounts/oidc/authentik/login/callback/
Typos here will cause 400 errors. Copy-paste, do not hand-type.
- Under "Client type", choose "Confidential".
- Save the client ID and secret. You will need these in the previous section.
Now create a Signing Key. Go to System > Crypto > Certificates.
- Click Create.
- Choose "Generate" and select "RSA".
- Set the key size to 2048 bits.
- Do not use EC. This will cause the "Expected RSA, got EC" error seen in GitHub issue #11788.
In the OAuth2/OIDC provider settings, under "Signing Key", select the RSA key you just created.
Final step: in the OAuth2 provider settings, find "Authorization Flow Settings". Uncheck "Encryption required". Paperless-ngx does not support encrypted tokens. If you skip this, logins will fail silently.
Common Pitfalls and Fixes
Pitfall 1: "Expected key type RSA, got EC"
Your signing key is elliptic curve, not RSA. Authentik allows both. Paperless-ngx only accepts RSA. Solution: delete the EC key and generate a new RSA certificate (2048-bit minimum). Select it in the provider settings.
Pitfall 2: Redirect URI mismatch
You set the callback URL in Authentik to https://<paperless-domain>/accounts/oidc/authentik/login/callback/ but Paperless sends https://<paperless-domain>/accounts/oidc/authentik/login/callback (no trailing slash). Result: 400 error. Solution: Authentik is strict about trailing slashes. The URL in this guide includes a trailing slash; use it exactly.
Pitfall 3: Token endpoint auth failure
You set token_auth_method to client_secret_basic (the default in some examples). Authentik returns 401 when validating the token. Solution: use client_secret_post as shown above. This sends the secret in the request body, which Authentik expects.
Pitfall 4: Encryption required
Authentik is set to require encrypted tokens. Paperless sends unencrypted tokens. Result: silent login failure (user clicks "Authentik", page refreshes, no error message). Solution: in Authentik's OAuth2 provider, uncheck "Authorization Flow Settings: Encryption required".
Pitfall 5: PKCE mismatch
Paperless-ngx v3.3.x did not send PKCE (Proof Key for Code Exchange). Later versions do. If your Authentik provider requires PKCE but Paperless is v3.3.x, logins fail. Solution: upgrade Paperless-ngx to v3.4.0 or later, or disable PKCE in Authentik.
Managing Users and Groups After Login
Once OIDC is working, users log in with their Authentik credentials. Paperless creates a local user account on first login (linked to the OIDC identity). Do not delete this local account; it breaks the link.
Auto-signup: By default, any user in Authentik can log in and create a Paperless account. This is convenient for self-hosted setups but risky if Authentik is exposed. Solution: in Paperless, go to Django admin (Authentik must be linked to a staff account first), then Sites > Social Applications. Set "Auto-verify emails" to true if users will auto-create accounts.
Group sync: Paperless-ngx v3.4.0+ supports automatic group sync. When a user logs in via OIDC, their groups from Authentik sync to Paperless. Configure this in Authentik's property mapping (requires custom Python). The official Authentik integration guide includes the exact mapping code.
Existing users: If you have local Paperless users and want them to log in via OIDC, link their accounts in Django admin. This prevents duplicate accounts.
When OIDC Is Overkill
Not every Paperless-ngx deployment needs OIDC. Here is when you should skip it:
Single-user setups: You are the only person using Paperless. Local authentication is simpler. OIDC adds no value and one more failure point (your Authentik provider).
Air-gapped or offline deployments: Your Paperless instance cannot reach an OIDC provider. Users will never log in. This is a hard blocker.
Small teams (1-3 people): OIDC shines when you manage 5+ accounts and need group-based permissions. For three people, local accounts are faster to set up and maintain.
When OIDC provider is unreliable: If your Authentik instance crashes, users cannot log in to Paperless (after their OIDC session expires). This breaks the business. For critical document access, prefer redundant local auth or a hosted OIDC service (Okta) with SLAs.
Compliance does not require it: Some teams think OIDC is a security requirement. It is not. OIDC is a convenience and audit-trail feature. If your data is on HIPAA-compliant infrastructure and you back up Paperless correctly, local passwords work fine. See the DMS system overview for other security considerations.
Linking OIDC to Paperless Document Management
OIDC integrates cleanly with Paperless' tagging and permission model. When you have group-based access to documents, OIDC groups map to those permissions. For example:
- Create an "Finance" group in Authentik with certain users.
- In Paperless, tag documents with "Finance".
- Use a permission rule: group "Finance" can view "Finance" tag.
- Users in the Finance group, once synced, automatically see those documents.
This workflow requires careful property mapping in Authentik and custom group sync, but it eliminates manual permission assignment.
Troubleshooting and Next Steps
Testing the flow:
- Restart Paperless-ngx after changing env variables.
- Go to the Paperless login page (not the admin panel).
- Click "Authentik".
- You should be redirected to Authentik.
- Log in with an Authentik user.
- You should be redirected back to Paperless and logged in.
If this fails, check Paperless logs: docker-compose logs paperless. Look for "allauth" or "openid" errors. The error message usually pinpoints the issue (e.g., "Signing key is EC, not RSA").
If you are stuck:
- Check Authentik logs:
docker-compose logs authentik(if Authentik is in the same compose file). - Verify the client ID and secret are copied exactly (spaces break this).
- Confirm the redirect URI has a trailing slash.
- Test by visiting
https://<authentik-domain>/application/o/authorize/to confirm Authentik is reachable. - Enable debug logging in Paperless: set
PAPERLESS_LOGGING_LEVEL=debugand restart.
For production use, run Paperless on managed hosting where OIDC configuration, SSL certificates, and backups are handled for you. See our Paperless-ngx hosting plans for more.
Frequently Asked Questions
Can I use OIDC with local login disabled?
Yes. Set PAPERLESS_DISABLE_REGULAR_LOGIN=true and PAPERLESS_REDIRECT_LOGIN_TO_SSO=true. Users will only see the OIDC provider button. Gotcha: you cannot use the Django admin login form with this setting. Create an OIDC-linked superuser first.
What happens if my OIDC provider goes offline?
Users with valid OIDC sessions can still access Paperless (session cookies remain valid). Once sessions expire (default 14 days in Authentik), users cannot log in. This is why OIDC is risky for mission-critical access. Use a hosted OIDC service with uptime SLA, or keep local auth as a fallback.
Can I use multiple OIDC providers?
Yes. Add multiple entries to PAPERLESS_SOCIALACCOUNT_PROVIDERS. Each provider gets its own button on the login page. Users can link multiple identities in their profile.
How do I sync groups automatically?
Paperless-ngx v3.4.0+ has built-in group sync when properly configured. Set a property mapping in your OIDC provider to send group names in the token. Paperless will create groups and assign users. The Authentik integration guide has the exact Python code.
What if I already have local users?
Create a new OIDC-linked account or link OIDC to an existing local account in Django admin. Do not delete the local account. The OIDC identity is attached to the account, not a replacement.
Can I use OAuth 2.0 instead of OIDC?
No. Paperless-ngx expects OpenID Connect, which includes identity claims (user info). Plain OAuth 2.0 only gives access tokens. Use an OIDC provider.
Is OIDC more secure than local passwords?
Not inherently. OIDC centralizes authentication (good for audit). But if the OIDC provider is compromised, all linked apps are compromised. Use strong passwords and MFA in Authentik to mitigate this.
The Bottom Line
OIDC in Paperless-ngx is powerful for teams. It gives you single sign-on, centralized group management, and audit trails. But setup requires care with keys, URLs, and auth methods. The common pitfalls (RSA vs EC, trailing slashes, encryption settings) are well-documented once you know to look for them. For single-user setups or air-gapped deployments, skip OIDC and stick with local auth. For small teams with modest compliance needs, Authentik self-hosted works. For larger teams or when reliability matters, consider managed Paperless-ngx hosting where configuration is handled for you: get started free on Opsily.