Skip to content

Commit a1d1fa4

Browse files
docs: document configuring multiple identity providers of the same type
Explain the object form of `identityProviders` (keyed by id) and how the callback URL is derived from the chosen id, with a self-hosted + gitlab.com example. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8f1b5ac commit a1d1fa4

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

docs/docs/configuration/idp.mdx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import LicenseKeyRequired from '/snippets/license-key-required.mdx'
1010
You can connect Sourcebot to various **external identity providers** to associate a Sourcebot user with one or more external service accounts (ex. Google, GitHub, etc).
1111

1212
External identity providers can be used for [authentication](/docs/configuration/auth) and/or [permission syncing](/docs/features/permission-syncing). They're defined in the
13-
[config file](/docs/configuration/config-file) in the top-level `identityProviders` object:
13+
[config file](/docs/configuration/config-file) in the top-level `identityProviders` array:
1414

1515
```json wrap icon="code" Example config with both google and github identity providers defined
1616
{
@@ -42,6 +42,8 @@ External identity providers can be used for [authentication](/docs/configuration
4242

4343
Secret values (such as `clientId` and `clientSecret`) can be provided as environment variables or Google Cloud secrets via [tokens](/docs/configuration/config-file#tokens).
4444

45+
To configure **multiple providers of the same type**, see [Configuring multiple providers of the same type](#configuring-multiple-providers-of-the-same-type).
46+
4547
# Supported External Identity Providers
4648

4749
Sourcebot uses [Auth.js](https://authjs.dev/) to connect to external identity providers. If there's a provider supported by Auth.js that you don't see below, please submit a
@@ -642,4 +644,46 @@ GCP IAP works differently from other identity providers. Instead of redirecting
642644
</Steps>
643645
</Accordion>
644646

647+
# Configuring multiple providers of the same type
648+
649+
By default, each provider in the `identityProviders` array is identified by an **id** equal to its `provider` value. This id determines the provider's OAuth **callback URL** (sometimes called the redirect URL):
650+
651+
```
652+
<sourcebot_url>/api/auth/callback/<id>
653+
```
654+
655+
This is why the examples above register callback URLs like `<sourcebot_url>/api/auth/callback/github`. The array form supports only **one instance per provider type**.
656+
657+
To configure **multiple instances of the same provider type** (for example, gitlab.com alongside a self-hosted GitLab instance), switch `identityProviders` to its object form, where you assign each provider a unique id:
658+
659+
```json wrap icon="code" Two GitLab providers, one for gitlab.com and one for a self-hosted instance
660+
{
661+
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
662+
"identityProviders": {
663+
"gitlab-cloud": {
664+
"provider": "gitlab",
665+
"purpose": "sso",
666+
"clientId": { "env": "GITLAB_CLOUD_CLIENT_ID" },
667+
"clientSecret": { "env": "GITLAB_CLOUD_CLIENT_SECRET" }
668+
},
669+
"gitlab-selfhosted": {
670+
"provider": "gitlab",
671+
"purpose": "sso",
672+
"baseUrl": "https://gitlab.example.com",
673+
"clientId": { "env": "GITLAB_SELFHOSTED_CLIENT_ID" },
674+
"clientSecret": { "env": "GITLAB_SELFHOSTED_CLIENT_SECRET" }
675+
}
676+
}
677+
}
678+
```
679+
680+
Each provider keeps the same fields documented above. The only differences are:
681+
682+
- `identityProviders` is an **object** keyed by id instead of an array.
683+
- The id you choose (`gitlab-cloud`, `gitlab-selfhosted`) sets the callback URL, so you register `<sourcebot_url>/api/auth/callback/gitlab-cloud` and `<sourcebot_url>/api/auth/callback/gitlab-selfhosted` with their respective OAuth clients.
684+
685+
<Note>
686+
Each instance needs its own OAuth client (its own `clientId` and `clientSecret`) registered with the matching callback URL.
687+
</Note>
688+
645689

0 commit comments

Comments
 (0)