SSO and Authentication Providers
Relevant source files
The following files were used as context for generating this wiki page:- packages/backend-core/src/middleware/passport/sso/google.ts
- packages/backend-core/src/middleware/passport/sso/oidc.ts
- packages/worker/src/api/routes/global/tests/scim.spec.ts
- packages/types/src/api/web/global/scim/users.ts
- packages/builder/src/settings/pages/auth/index.svelte
- packages/builder/src/settings/pages/auth/google.svelte
- packages/backend-core/tests/core/utilities/structures/sso.ts
Budibase integrates with external identity providers to offer Single Sign-On (SSO) capabilities, allowing users to authenticate using their existing credentials. The system is built upon Passport.js, utilizing different "strategies" for each provider. Currently, it supports Google and any OpenID Connect (OIDC) compliant provider.
The SSO functionality is complemented by SCIM (System for Cross-domain Identity Management), which enables automated user provisioning and de-provisioning from identity providers. This ensures that user access is synchronized between the identity provider and Budibase. Configuration for these providers is managed through the Budibase builder interface, with backend middleware handling the authentication flows.
Architecture Overview
The authentication architecture relies on Passport.js middleware. For each configured and activated SSO provider, a corresponding Passport strategy is initialized. When a user attempts to log in via SSO, they are redirected to the provider. After successful authentication, the provider redirects the user back to a Budibase callback URL with an authorization code or tokens. The Passport strategy's verify function then processes the user's profile, normalizes it, and either finds an existing Budibase user or provisions a new one.
This diagram illustrates the high-level flow of SSO authentication components.
Google SSO Integration
Integration with Google is handled by the passport-google-oauth20 strategy. It allows users to log in with their Google accounts.
Configuration
The Google SSO provider is configured via the authentication settings page in the Budibase builder. The necessary configuration is stored as a google config document in the database.
| Field | Description | Source File |
|---|---|---|
clientID | The Google OAuth 2.0 Client ID. | packages/builder/src/settings/pages/auth/google.svelte:40 |
clientSecret | The Google OAuth 2.0 Client Secret. | packages/builder/src/settings/pages/auth/google.svelte:41 |
callbackURL | The URL to which Google will redirect users after authentication. This is read-only and derived from the platform URL. | packages/builder/src/settings/pages/auth/google.svelte:45 |
sheetsURL | A separate callback URL specifically for Google Sheets datasource authentication. | packages/builder/src/settings/pages/auth/google.svelte:53 |
activated | A boolean toggle to enable or disable the Google login option. | packages/builder/src/settings/pages/auth/google.svelte:145 |
The backend GoogleStrategy is initialized with the clientID, clientSecret, and callbackURL. It requests the profile and email scopes from Google.
Sources: packages/builder/src/settings/pages/auth/google.svelte, packages/backend-core/src/middleware/passport/sso/google.ts:31-39, packages/backend-core/tests/core/utilities/structures/sso.ts:101-107
Authentication Flow
The following sequence diagram shows the Google SSO authentication process.
OIDC Integration
Budibase supports any OpenID Connect (OIDC) compliant identity provider. This is implemented using the passport-openidconnect strategy.
Configuration
OIDC configuration is more extensive than Google's, allowing for greater flexibility. It is managed on the same authentication settings page.
| Field | Description | Source File |
|---|---|---|
configUrl | The URL to the provider's .well-known/openid-configuration discovery document. | packages/builder/src/settings/pages/auth/index.svelte:201 |
clientID | The OIDC client ID. | packages/builder/src/settings/pages/auth/index.svelte:202 |
clientSecret | The OIDC client secret. | packages/builder/src/settings/pages/auth/index.svelte:203 |
callbackURL | The read-only callback URL. | packages/builder/src/settings/pages/auth/index.svelte:207 |
name | A custom name for the login button. | packages/builder/src/settings/pages/auth/index.svelte:235 |
logo | A custom icon for the login button. | packages/builder/src/settings/pages/auth/index.svelte:239 |
pkce | The Proof Key for Code Exchange (PKCE) method. Can be S256 or plain. This is an enterprise feature. | packages/builder/src/settings/pages/auth/index.svelte:252 |
scopes | An array of scopes to request from the provider. Defaults include profile, email, offline_access. | packages/builder/src/settings/pages/auth/index.svelte:292 |
activated | A boolean to enable or disable this OIDC provider. | packages/builder/src/settings/pages/auth/index.svelte:264 |
The backend dynamically creates an OIDCStrategy for each activated configuration. It uses the configUrl to fetch endpoints like authorizationURL, tokenURL, and userInfoURL.
Sources: packages/builder/src/settings/pages/auth/index.svelte, packages/backend-core/src/middleware/passport/sso/oidc.ts:40-66, packages/backend-core/tests/core/utilities/structures/sso.ts:55-70
Authentication Flow with Discovery
The OIDC flow includes a discovery step to fetch the provider's configuration.
SCIM User Provisioning
Budibase supports SCIM 2.0 for user provisioning, which is often used in conjunction with SSO. This allows identity providers to create, update, and deactivate users in Budibase automatically. This is an enterprise-only feature.
SCIM API Endpoints
The SCIM implementation exposes a set of standard endpoints under /api/global/scim/v2/.
| Method | Endpoint | Description | Source File |
|---|---|---|---|
POST | /Users | Creates a new user. | packages/worker/src/api/routes/global/tests/scim.spec.ts:43 |
GET | /Users | Lists and searches for users. Supports filtering by userName. | packages/worker/src/api/routes/global/tests/scim.spec.ts:114 |
GET | /Users/:id | Retrieves a single user by their ID. | packages/worker/src/api/routes/global/tests/scim.spec.ts:153 |
PATCH | /Users/:id | Partially updates a user, commonly used to change the active status. | packages/worker/src/api/routes/global/tests/scim.spec.ts:182 |
PUT | /Users/:id | Replaces a user's attributes entirely. | packages/worker/src/api/routes/global/tests/scim.spec.ts:241 |
SCIM User Schema
The user object follows the SCIM standard. Key fields are defined in the SCIMUser interface.
// A simplified representation of the SCIMUser interface
interface SCIMUser {
schemas: ["urn:ietf:params:scim:schemas:core:2.0:User"];
id: string;
userName: string;
name: {
givenName?: string;
familyName?: string;
};
emails: Array<{
primary: boolean;
value: string;
type: string;
}>;
active: boolean;
meta: {
resourceType: "User";
created: string;
lastModified: string;
location: string;
};
}
Source: packages/types/src/api/web/global/scim/users.ts:19-40
This structure is used in API requests and responses for creating and managing users via SCIM. For example, a PATCH operation to deactivate a user would send a payload like: {"op": "replace", "value": {"active": false}}.
Source: packages/worker/src/api/routes/global/tests/scim.spec.ts:221-225