Self-Hosting

Configure

Google OAuth Authentication

Integrating Google OAuth with your Formbricks instance allows users to log in using their Google credentials, ensuring a secure and streamlined user experience. This guide will walk you through the process of setting up Google OAuth for your Formbricks instance.

Requirements

  • A Google Cloud Platform (GCP) account.
  • A Formbricks instance running and accessible.

Steps

  1. Create a GCP Project:

    • Navigate to the GCP Console.
    • From the projects list, select a project or create a new one.
  2. Setting up OAuth 2.0:

    • If the APIs & services page isn't already open, open the console left side menu and select APIs & services.
    • On the left, click Credentials.
    • Click Create Credentials, then select OAuth client ID.
  3. Configure OAuth Consent Screen:

    • If this is your first time creating a client ID, configure your consent screen by clicking Consent Screen.
    • Fill in the necessary details and under Authorized domains, add the domain where your Formbricks instance is hosted.
  4. Create OAuth 2.0 Client IDs:

    • Select the application type Web application for your project and enter any additional information required.
    • Ensure to specify authorized JavaScript origins and authorized redirect URIs.

Configuration URLs

Authorized JavaScript origins: {WEBAPP_URL}
Authorized redirect URIs: {WEBAPP_URL}/api/auth/callback/google ```



5. **Update Environment Variables in Docker**:
- To integrate the Google OAuth, you have two options: either update the environment variables in the docker-compose file or directly add them to the running container.
- In your Docker setup directory, open the `.env` file, and add or update the following lines with the `Client ID` and `Client Secret` obtained from Google Cloud Platform:
- Alternatively, you can add the environment variables directly to the running container using the following commands (replace `container_id` with your actual Docker container ID):




```sh {{ title: 'Shell commands' }}
docker exec -it container_id /bin/bash
export GOOGLE_CLIENT_ID=your-client-id-here
export GOOGLE_CLIENT_SECRET=your-client-secret-here
exit
  1. Restart Your Formbricks Instance:
    • Note: Restarting your Docker containers may cause a brief period of downtime. Plan accordingly.
    • Once the environment variables have been updated, it's crucial to restart your Docker containers to apply the changes. This ensures that your Formbricks instance can utilize the new Google OAuth configuration for user authentication. Here's how you can do it:
    • Navigate to your Docker setup directory where your docker-compose.yml file is located.
    • Run the following command to bring down your current Docker containers and then bring them back up with the updated environment configuration:

Azure SSO Integration

Have an Azure Active Directory (AAD) instance? Integrate it with your Formbricks instance to allow users to log in using their existing AAD credentials. This guide will walk you through the process of setting up Azure SSO for your Formbricks instance.

Requirements

  • An Azure Active Directory (AAD) instance.
  • A Formbricks instance running and accessible.

Steps

  1. Create a new Tenant in Azure Active Directory as per their official documentation.
  2. Add Users & Groups to your AAD instance.
  3. Now we need to fill the below environment variables in our Formbricks instance so get them from your AD configuration:
    • AZUREAD_CLIENT_ID
    • AZUREAD_CLIENT_SECRET
    • AZUREAD_TENANT_ID
  4. Update these environment variables in your docker-compose.yml or pass it like your other environment variables to the Formbricks container.
  5. Restart your Formbricks instance.
  6. You're all set! Users can now signup & log in using their AAD credentials.

OpenID Integration

Integrating your own OIDC (OpenID Connect) instance with your Formbricks instance allows users to log in using their OIDC credentials, ensuring a secure and streamlined user experience. Please follow the steps below to set up OIDC for your Formbricks instance.

  1. Configure your OIDC provider & get the following variables:
    • OIDC_CLIENT_ID
    • OIDC_CLIENT_SECRET
    • OIDC_ISSUER
    • OIDC_SIGNING_ALGORITHM
  1. Update these environment variables in your docker-compose.yml or pass it directly to the running container.

An example configuration for a FusionAuth OpenID Connect in Formbricks would look like:

Formbricks Env for FusionAuth OIDC

OIDC_CLIENT_ID=59cada54-56d4-4aa8-a5e7-5823bbe0e5b7
OIDC_CLIENT_SECRET=4f4dwP0ZoOAqMW8fM9290A7uIS3E8Xg29xe1umhlB_s
OIDC_ISSUER=http://localhost:9011
OIDC_DISPLAY_NAME=FusionAuth
OIDC_SIGNING_ALGORITHM=HS256
  1. Set an environment variable OIDC_DISPLAY_NAME to the display name of your OIDC provider.

  2. Restart your Formbricks instance.

  3. You're all set! Users can now signup & log in using their OIDC credentials.

Important Run-time Variables

These variables can be provided at the runtime i.e. in your docker-compose file.

VariableDescriptionRequiredDefault
WEBAPP_URLBase URL of the site.requiredhttp://localhost:3000
DATABASE_URLDatabase URL with credentials.required
NEXTAUTH_SECRETSecret for NextAuth, used for session signing and encryption.required(Generated by the user)
ENCRYPTION_KEYSecret for used by Formbricks for data encryptionrequired(Generated by the user)
NEXTAUTH_URLLocation of the auth server. By default, this is the Formbricks docker instance itself.requiredhttp://localhost:3000
UPLOADS_DIRLocal directory for storing uploads.optional./uploads
S3_ACCESS_KEYAccess key for S3.optional(resolved by the AWS SDK)
S3_SECRET_KEYSecret key for S3.optional(resolved by the AWS SDK)
S3_REGIONRegion for S3.optional(resolved by the AWS SDK)
S3_BUCKET_NAMES3 bucket name for data storage. Formbricks enables S3 storage when this is set.optional (required if S3 is enabled)
S3_ENDPOINTEndpoint for S3.optional(resolved by the AWS SDK)
PRIVACY_URLURL for privacy policy.optional
TERMS_URLURL for terms of service.optional
IMPRINT_URLURL for imprint.optional
SIGNUP_DISABLEDDisables the ability for new users to create an account if set to 1.optional
EMAIL_AUTH_DISABLEDDisables the ability for users to signup or login via email and password if set to 1.optional
PASSWORD_RESET_DISABLEDDisables password reset functionality if set to 1.optional
EMAIL_VERIFICATION_DISABLEDDisables email verification if set to 1.optional
RATE_LIMITING_DISABLEDDisables rate limiting if set to 1.optional
INVITE_DISABLEDDisables the ability for invited users to create an account if set to 1.optional
MAIL_FROMEmail address to send emails from.optional (required if email services are to be enabled)
SMTP_HOSTHost URL of your SMTP server.optional (required if email services are to be enabled)
SMTP_PORTHost Port of your SMTP server.optional (required if email services are to be enabled)
SMTP_USERUsername for your SMTP Server.optional (required if email services are to be enabled)
SMTP_PASSWORDPassword for your SMTP Server.optional (required if email services are to be enabled)
SMTP_SECURE_ENABLEDSMTP secure connection. For using TLS, set to 1 else to 0.optional (required if email services are to be enabled)
GITHUB_IDClient ID for GitHub.optional (required if GitHub auth is enabled)
GITHUB_SECRETSecret for GitHub.optional (required if GitHub auth is enabled)
GOOGLE_CLIENT_IDClient ID for Google.optional (required if Google auth is enabled)
GOOGLE_CLIENT_SECRETSecret for Google.optional (required if Google auth is enabled)
CRON_SECRETAPI Secret for running cron jobs.optional
STRIPE_SECRET_KEYSecret key for Stripe integration.optional
STRIPE_WEBHOOK_SECRETWebhook secret for Stripe integration.optional
TELEMETRY_DISABLEDDisables telemetry if set to 1.optional
INSTANCE_IDInstance ID for Formbricks Cloud to be sent to Telemetry.optional
INTERNAL_SECRETInternal Secret (Currently we overwrite the value with a random value).optional
DEFAULT_BRAND_COLORDefault brand color for your app (Can be overwritten from the UI as well).optional#64748b
DEFAULT_TEAM_IDAutomatically assign new users to a specific team when joiningoptional
DEFAULT_TEAM_ROLERole of the user in the default team.optionaladmin
ONBOARDING_DISABLEDDisables onboarding for new users if set to 1optional
OIDC_DISPLAY_NAMEDisplay name for Custom OpenID Connect Provideroptional
OIDC_CLIENT_IDClient ID for Custom OpenID Connect Provideroptional (required if OIDC auth is enabled)
OIDC_CLIENT_SECRETSecret for Custom OpenID Connect Provideroptional (required if OIDC auth is enabled)
OIDC_ISSUERIssuer URL for Custom OpenID Connect Provider (should have .well-known configured at this)optional (required if OIDC auth is enabled)
OIDC_SIGNING_ALGORITHMSigning Algorithm for Custom OpenID Connect ProvideroptionalRS256
OPENTELEMETRY_LISTENER_URLURL for OpenTelemetry listener inside Formbricks.optional

Build-time Variables

These variables must be provided at the time of the docker build and would require rebuilding the image.

VariableDescriptionRequiredDefault
NEXT_PUBLIC_FORMBRICKS_API_HOSTHost for the Formbricks API to use inside Formbricks.optional
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_IDFormbricks environment ID for use inside Formbricks.optional
NEXT_PUBLIC_POSTHOG_API_KEYAPI key to use PostHog analytics inside Formbricks.optional
NEXT_PUBLIC_POSTHOG_API_HOSTHost to use PostHog analytics inside Formbricks.optional
NEXT_PUBLIC_SENTRY_DSNDSN for Sentry error tracking inside Formbricks.optional

Still facing issues? Join our Discord! and we'd be glad to assist you!

Was this page helpful?