Skip to content

Authentication

Ephor delegates authentication to oauth2-proxy, which sits in front of the API and authenticates users against an identity provider. After a successful login, oauth2-proxy forwards identity information to the API via HTTP headers.

How It Works

oauth2-proxy injects the following headers into every authenticated request:

HeaderDescription
X-Forwarded-UserUsername or user ID
X-Forwarded-EmailEmail address
X-Forwarded-GroupsComma-separated list of group memberships
X-Forwarded-Preferred-UsernameDisplay name (takes precedence over X-Forwarded-User)
X-Forwarded-Access-TokenOAuth access token (optional)

Ephor reads these headers to identify the current user and resolve their role. See Roles and Permissions for how groups map to roles.

Keycloak (OIDC)

A ready-to-use Keycloak stack is included for local development and testing:

bash
docker compose -f docker-compose.oauth2.yml up

This starts Keycloak on port 8180 with a pre-configured ephor realm and the following test users (password for all: password):

EmailGroupRole
admin@example.comephor-adminsAdmin
lead@example.comephor-leadsLead
analyst@example.comephor-analystsAnalyst
viewer@example.comephor-viewersViewer

The Keycloak admin console is at http://localhost:8180 with credentials admin / admin.

oauth2-proxy is pre-configured to use this Keycloak instance. Group claims are extracted from the JWT token automatically.

GitHub OAuth

To authenticate with GitHub organization teams:

bash
docker compose -f docker-compose.github-oauth2.yml up

Prerequisites

  1. Create a GitHub OAuth App in your organization settings under Developer settings > OAuth Apps.
  2. Set the callback URL to http://<your-host>/oauth2/callback.
  3. Create the following teams in your GitHub organization:
Team slugRole
ephor-viewersViewer
ephor-analystsAnalyst
ephor-leadsLead
ephor-adminsAdmin

Required Environment Variables

VariableDescription
GITHUB_OAUTH_CLIENT_IDClient ID from your GitHub OAuth App
GITHUB_OAUTH_CLIENT_SECRETClient secret from your GitHub OAuth App
GITHUB_ORGGitHub organization name
GITHUB_TOKENPersonal access token with read:org scope (for team sync)

Users must be members of at least one of the configured teams to access Ephor.

Custom Provider

Any identity provider supported by oauth2-proxy works with Ephor. Configure oauth2-proxy for your provider and ensure it forwards the X-Forwarded-User, X-Forwarded-Email, and X-Forwarded-Groups headers.

Group names in X-Forwarded-Groups must match the configured group-to-role mappings. The defaults are ephor-viewers, ephor-analysts, ephor-leads, and ephor-admins.

Refer to the oauth2-proxy provider documentation for setup details.

Development Mode

For local development without an identity provider, authentication can be bypassed entirely by setting AUTH_DEV_ENABLED=true. This injects a configurable development user on every request.

VariableDefaultDescription
AUTH_DEV_USERNAMEdev-userUsername
AUTH_DEV_EMAILdev@localhostEmail
AUTH_DEV_GROUPSephor-admins,developers,security-teamComma-separated groups
AUTH_DEV_DISPLAY_NAMEDevelopment UserDisplay name

This mode is enabled by default in the standard docker-compose.yml stack.

WARNING

Never enable AUTH_DEV_ENABLED in production. It bypasses all authentication and grants access to anyone who can reach the application.

User Directory Sync

Ephor can sync users and groups from the identity provider into its local database for user management features. Configure the provider with EPHOR_USER_DIRECTORY_PROVIDER:

ProviderSync intervalDescription
internal--Users managed in the database (default)
keycloak15 minutesSync users and groups from Keycloak
github30 minutesSync users and team memberships from GitHub
none--No user sync or lookup

See the Configuration Reference for all provider-specific settings.

Licensed under AGPL v3