Keycloak OIDC is part of the Formbricks Enterprise Edition
Requirements
- A running Keycloak instance with a configured realm and users.
- A self-hosted Formbricks instance with a valid Enterprise license.
- The Formbricks callback URI:
{WEBAPP_URL}/api/auth/callback/openid
Setting up Keycloak OIDC
Create a new client in Keycloak
- Log in to your Keycloak admin console.
- Select the realm you want to use (e.g.,
production). - Navigate to Clients in the left menu and click Create client.
- Set Client type to
OpenID Connect. - Choose a Client ID (e.g.,
formbricks) and click Next.
Configure client authentication
- Enable Client authentication (this makes the client “confidential” and generates a client secret).
- Under Authentication flow, ensure Standard flow is enabled.
- Click Next.
Formbricks uses PKCE (Proof Key for Code Exchange) for added security. Modern Keycloak versions (21+) support PKCE automatically for confidential clients. No additional PKCE configuration is needed.
Set the redirect URI
- Under Valid redirect URIs, add your Formbricks callback URI:
your-formbricks-domain.com with your actual Formbricks URL.- Click Save.
Copy the client secret
- After saving, go to the Credentials tab of your newly created client.
- Copy the Client secret value — you will need this for the Formbricks configuration.
Determine the issuer URL
The OIDC issuer URL follows this pattern:For example, if your Keycloak runs at
login.example.com and your realm is called production:You can verify the issuer URL by navigating to
https://your-keycloak-domain.com/realms/your-realm-name/.well-known/openid-configuration in your browser. It should return a JSON document with the OIDC discovery endpoints.Configure Formbricks environment variables
Add the following environment variables to your Formbricks
.env file or docker-compose.yml:Formbricks Env for Keycloak OIDC
| Variable | Description |
|---|---|
OIDC_CLIENT_ID | The Client ID you chose in Keycloak (e.g., formbricks). |
OIDC_CLIENT_SECRET | The client secret from the Credentials tab. |
OIDC_ISSUER | Your Keycloak realm URL (see step above). |
OIDC_DISPLAY_NAME | The label shown on the Formbricks login button. |
OIDC_SIGNING_ALGORITHM | Optional. Keycloak and Formbricks both default to RS256. Only set this if your realm uses a different algorithm. |
To disable email/password login entirely and force all users through Keycloak, set
EMAIL_AUTH_DISABLED=1. This hides the email/password form on the login page.Automatic User Provisioning
By default, new SSO users must be invited by an organization admin before they can access Formbricks. To allow Keycloak users to join automatically and be assigned to a team, configure the following additional environment variables:Automatic User Provisioning
| Variable | Description |
|---|---|
AUTH_SKIP_INVITE_FOR_SSO | Set to 1 to let SSO users create an account without a manual invite. |
AUTH_SSO_DEFAULT_TEAM_ID | The ID of the team that new SSO users are automatically added to. The organization is determined from this team. |
Finding Your Team ID
- Log in to Formbricks as an admin.
- Go to Organization Settings → Teams.
- Click Manage Team on the team you want to use as the default.
- The Team ID is displayed in the modal.
The Teams feature requires the Role-Based Access Control (RBAC) add-on on your Enterprise license. If you don’t see the Teams section in Organization Settings, contact Formbricks support to enable it.
How It Works
WhenAUTH_SKIP_INVITE_FOR_SSO=1 and AUTH_SSO_DEFAULT_TEAM_ID are both set:
- A user authenticates through Keycloak for the first time.
- Formbricks creates a new user account.
- The user is automatically added as a member of the organization that owns the specified team.
- The user is assigned to the default team, granting them access to all projects associated with that team.
Full Configuration Example
A complete.env configuration for Keycloak OIDC with automatic user provisioning:
Complete Keycloak OIDC Configuration
Troubleshooting
Users see 'No access to Workspaces' after login
Users see 'No access to Workspaces' after login
This means the user was added to the organization but not assigned to a team. Verify that:
AUTH_SSO_DEFAULT_TEAM_IDis set correctly (the env variable name isAUTH_SSO_DEFAULT_TEAM_ID, notDEFAULT_TEAM_ID).- The Team ID is a valid cuid that exists in your database.
- The team is linked to a project via Project Teams settings.
Users see 'No membership found' after login
Users see 'No membership found' after login
Formbricks determines the organization automatically from the
AUTH_SSO_DEFAULT_TEAM_ID — you do not need to set a separate organization ID. If this error appears:- Verify the team specified in
AUTH_SSO_DEFAULT_TEAM_IDexists and belongs to the correct organization. - Confirm your Enterprise license includes the RBAC feature (required for Teams).
- Ensure the organization has an active billing plan that supports access control.
OIDC login button does not appear
OIDC login button does not appear
Authentication fails with a redirect error
Authentication fails with a redirect error
- Verify the Valid redirect URI in your Keycloak client matches exactly:
{WEBAPP_URL}/api/auth/callback/openid - Check that the OIDC issuer URL is reachable from your Formbricks server. You can test with: