Skip to main content

Overview

Kaneo supports custom OAuth 2.0 and OpenID Connect (OIDC) providers, allowing you to integrate with any standards-compliant identity provider such as Keycloak, Auth0, Okta, Azure AD, or self-hosted solutions like Pocket ID.

Configuration

To configure a custom OAuth/OIDC provider, you need to set the following environment variables in your .env file:

Required Variables

VariableDescriptionExample
CUSTOM_OAUTH_CLIENT_IDOAuth client ID from your provider2b1ae9df-8d25-4dbc-8cc8-f8f2c1ef6bd0
CUSTOM_OAUTH_CLIENT_SECRETOAuth client secret from your providerNzDjplDsdQyP062wTmkZ8kyiaziBag0N
CUSTOM_OAUTH_AUTHORIZATION_URLAuthorization endpoint URLhttps://id.example.com/authorize
CUSTOM_OAUTH_TOKEN_URLToken exchange endpoint URLhttps://id.example.com/api/oidc/token
CUSTOM_OAUTH_USER_INFO_URLUser info endpoint URLhttps://id.example.com/api/oidc/userinfo

Optional Variables

VariableDescriptionDefault
CUSTOM_OAUTH_DISCOVERY_URLOpenID Connect discovery document URL-
CUSTOM_OAUTH_SCOPESComma-separated list of OAuth scopesprofile,email
CUSTOM_OAUTH_RESPONSE_TYPEOAuth response typecode
CUSTOM_AUTH_PKCEEnable/disable PKCE (Proof Key for Code Exchange)true
CUSTOM_OAUTH_LOGOUT_URLLogout endpoint URL (optional)https://id.example.com/api/oidc/logout
CUSTOM_OAUTH_AUTO_LOGINAuto-redirect to the custom OAuth provider, bypassing the login pagefalse

Setup Steps

1. Configure Your OAuth Provider

First, create an OAuth 2.0 or OIDC application in your identity provider:
  1. Log in to your identity provider’s admin console
  2. Create a new OAuth 2.0 or OIDC application
  3. Set the redirect URI to: {KANEO_API_URL}/api/auth/oauth2/callback/custom
    • Example: https://api.kaneo.example.com/api/auth/oauth2/callback/custom
  4. Copy the client ID and client secret
  5. Note the authorization, token, and userinfo endpoint URLs

2. Set Environment Variables

Add the following to your .env file:

3. Restart Services

After updating the environment variables, restart your Kaneo services:

Example Configurations

Pocket ID

Keycloak

Auth0

Usage

Once configured, users will see a “Continue with OIDC” button on the sign-in page. The system will automatically remember the last used login method for each user.

Auto-Login (Skip the Login Page)

If you want to bypass the login page entirely and automatically redirect users to your identity provider, set:
When enabled, users visiting the sign-in page will be immediately redirected to your custom OAuth provider without seeing the Kaneo login page. This is ideal for organizations that use a single identity provider for all authentication.

Troubleshooting

”Invalid code verifier” Error

This error typically indicates a PKCE configuration issue. Try setting:
Some OAuth providers don’t support PKCE or have it disabled by default.

Missing User Information

Ensure your OAuth scopes include at least profile and email:
Some providers require openid scope as well:

Redirect URI Mismatch

Verify that your redirect URI in the OAuth provider matches exactly:
For example, if KANEO_API_URL=https://api.kaneo.example.com, the redirect URI should be:

Discovery URL

If your provider supports OpenID Connect, you can use the discovery URL to automatically configure most settings:
This will automatically discover the authorization, token, and userinfo endpoints. However, you still need to provide the client ID and secret.

Account linking

When a user signs in with this provider using an email that already belongs to a Kaneo account (for example one created with email and password), Kaneo links the OIDC identity to that existing account instead of failing with error=account_not_linked. GitHub, Google, Discord, and this custom provider are trusted to link because they verify the user’s email. Because Kaneo does not require email verification on password signup, linking also applies to unverified local accounts so OIDC users are not locked out. If your instance allows password registration alongside OIDC, set DISABLE_PASSWORD_REGISTRATION=true (or require email verification) so that nobody can pre-register another person’s email and have an OIDC login linked into it.

Security Notes

  • Always use HTTPS in production
  • Keep your client secret secure and never commit it to version control
  • Enable PKCE when possible for enhanced security
  • Use the most restrictive scopes necessary for your use case