Skip to content

V4 #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

V4 #311

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9d11934
basic auth default changes
msukkari May 18, 2025
d5eb571
add max seat count check
msukkari May 18, 2025
1670fe7
prevent editing connections if config path is provided
msukkari May 19, 2025
d2f7be5
wip public access toggle
msukkari May 20, 2025
200febc
add support for account requests
msukkari May 20, 2025
ed90c19
prevent non owners from seeing requests and invites in settings
msukkari May 20, 2025
4a5f7c3
add public access support
msukkari May 20, 2025
0a27a1f
hide add repo button in unauthed case
msukkari May 20, 2025
6ef8295
made public access enable flag a setting
msukkari May 20, 2025
7ed63a2
add sso auth providers
msukkari May 20, 2025
ee6efc5
added ee sso logic
msukkari May 20, 2025
6e91693
add api key support
msukkari May 21, 2025
3eb0e5a
fix unauthed issue and ensure JIT provisioning only happens for oauth…
msukkari May 21, 2025
7df5c1e
add api key support to mcp and rest endpoints
msukkari May 21, 2025
10cfaee
add indicator to members side bar nav menu and fix minor nits
msukkari May 21, 2025
6f6a2eb
minor bug fix
msukkari May 21, 2025
971c44d
add emails for join requests
msukkari May 21, 2025
b8f40bc
add enterprise license settings page
msukkari May 22, 2025
8f9d079
prevent api key with the same name
msukkari May 22, 2025
5d0efd2
fix column alignment
msukkari May 22, 2025
246a73b
fix horizontal scroll bar issue
msukkari May 22, 2025
f71df1e
add ability to delete api keys
msukkari May 22, 2025
73d1710
bunch of fixes and docs
msukkari May 22, 2025
fef1172
added support for supplying custom entitlements list in license key'
msukkari May 22, 2025
87cfdfd
Merge branch 'main' into msukkarieh/auth2
msukkari May 22, 2025
aa46d46
UI nits
msukkari May 22, 2025
07e5d80
misc fixes
msukkari May 22, 2025
aa3ce38
doc fixes
msukkari May 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ SRC_TENANT_ENFORCEMENT_MODE=strict
AUTH_SECRET="00000000000000000000000000000000000000000000"
AUTH_URL="http://localhost:3000"
# AUTH_CREDENTIALS_LOGIN_ENABLED=true
# AUTH_GITHUB_CLIENT_ID=""
# AUTH_GITHUB_CLIENT_SECRET=""
# AUTH_GOOGLE_CLIENT_ID=""
# AUTH_GOOGLE_CLIENT_SECRET=""
# AUTH_EE_GITHUB_CLIENT_ID=""
# AUTH_EE_GITHUB_CLIENT_SECRET=""
# AUTH_EE_GOOGLE_CLIENT_ID=""
# AUTH_EE_GOOGLE_CLIENT_SECRET=""

DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
# CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exists)
Expand Down
11 changes: 5 additions & 6 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,16 @@
"group": "Getting Started",
"pages": [
"self-hosting/overview",
"self-hosting/configuration",
"self-hosting/license-key"
]
},
{
"group": "More",
"group": "Configuration",
"pages": [
"self-hosting/more/authentication",
"self-hosting/more/tenancy",
"self-hosting/more/transactional-emails",
"self-hosting/more/declarative-config"
"self-hosting/configuration/environment-variables",
"self-hosting/configuration/authentication",
"self-hosting/configuration/transactional-emails",
"self-hosting/configuration/declarative-config"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/agents/review-agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Before you get started, make sure you have an OpenAPI account that you can creat
directory that you mount to Sourcebot
![GitHub App Private Key](/images/github_app_private_key.png)
- `OPENAI_API_KEY`: Your OpenAI API key
- `REVIEW_AGENT_API_KEY`: The Sourcebot API key that the review agent uses to hit the Sourcebot API to fetch code context
- `REVIEW_AGENT_AUTO_REVIEW_ENABLED` (default: `false`): If enabled, the review agent will automatically review any new or updated PR. If disabled, you must invoke it using the command defined by `REVIEW_AGENT_REVIEW_COMMAND`
- `REVIEW_AGENT_REVIEW_COMMAND` (default: `review`): The command that invokes the review agent (ex. `/review`) when a user comments on the PR. Don't include the slash character in this value.

Expand All @@ -76,6 +77,7 @@ Before you get started, make sure you have an OpenAPI account that you can creat
GITHUB_APP_ID: "my-github-app-id"
GITHUB_APP_WEBHOOK_SECRET: "my-github-app-webhook-secret"
GITHUB_APP_PRIVATE_KEY_PATH: "/data/review-agent-key.pem"
REVIEW_AGENT_API_KEY: "sourcebot-my-key"
OPENAI_API_KEY: "sk-proj-my-open-api-key"
```
</Step>
Expand Down
1 change: 1 addition & 0 deletions docs/docs/more/mcp-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Parameters:
| Name | Default | Description |
|:-------------------------|:-----------------------|:--------------------------------------------------|
| `SOURCEBOT_HOST` | http://localhost:3000 | URL of your Sourcebot instance. |
| `SOURCEBOT_API_KEY` | - | Sourcebot API key. |
| `DEFAULT_MINIMUM_TOKENS` | 10000 | Minimum number of tokens to return in responses. |
| `DEFAULT_MATCHES` | 10000 | Number of code matches to fetch per search. |
| `DEFAULT_CONTEXT_LINES` | 5 | Lines of context to include above/below matches. |
3 changes: 1 addition & 2 deletions docs/docs/more/roles-and-permissions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ title: Roles and Permissions

<Note>Looking to sync permissions with your identify provider? We're working on it - [reach out](https://www.sourcebot.dev/contact) to us to learn more</Note>

If you're using Sourcebot Cloud, or are self-hosting with [authentication](/self-hosting/more/authentication) enabled, you may have multiple members in your organization. Each
member has a role which defines their permissions:
Each member has a role which defines their permissions within an organization:

| Role | Permission |
| :--- | :--------- |
Expand Down
Binary file modified docs/images/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/login_basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 0 additions & 59 deletions docs/self-hosting/configuration.mdx

This file was deleted.

109 changes: 109 additions & 0 deletions docs/self-hosting/configuration/authentication.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: Authentication
sidebarTitle: Authentication
---

<Warning>Make sure the `AUTH_URL` environment variable is [configured correctly](/self-hosting/configuration) when using Sourcebot behind a domain.</Warning>

Sourcebot has built-in authentication that gates access to your organization. OAuth, email codes, and email / password are supported.

The first account that's registered on a Sourcebot deployment is made the owner. All other users who register must be [approved](/self-hosting/configuration/authentication#approving-new-members) by the owner.

![Login Page](/images/login.png)


# Approving New Members

All account registrations after the first account must be approved by the owner. The owner can see all join requests by going into **Settings -> Members**.

If you have an [enterprise license](/self-hosting/license-key), you can enable [AUTH_EE_ENABLE_JIT_PROVISIONING](/self-hosting/configuration/authentication#enterprise-authentication-providers) to
have Sourcebot accounts automatically created and approved on registration.

You can setup emails to be sent when new join requests are created/approved by configurating [transactional emails](/self-hosting/configuration/transactional-emails)
# Authentication Providers

To enable an authentication provider in Sourcebot, configure the required environment variables for the provider. Under the hood, Sourcebot uses Auth.js which supports [many providers](https://authjs.dev/getting-started/authentication/oauth). Submit a [feature request on GitHub](https://github.com/sourcebot-dev/sourcebot/discussions/categories/ideas) if you want us to add support for a specific provider.

## Core Authentication Providers

### Email / Password
---
Email / password authentication is enabled by default. It can be **disabled** by setting `AUTH_CREDENTIALS_LOGIN_ENABLED` to `false`.

### Email codes
---
Email codes are 6 digit codes sent to a provided email. Email codes are enabled when transactional emails are configured using the following environment variables:

- `AUTH_EMAIL_CODE_LOGIN_ENABLED`
- `SMTP_CONNECTION_URL`
- `EMAIL_FROM_ADDRESS`


See [transactional emails](/self-hosting/configuration/transactional-emails) for more details.

## Enterprise Authentication Providers

The following authentication providers require an [enterprise license](/self-hosting/license-key) to be enabled.

By default, a new user registering using these providers must have their join request accepted by the owner of the organization to join. To allow a user to join automatically when
they register for the first time, set the `AUTH_EE_ENABLE_JIT_PROVISIONING` environment variable to `true`.

### GitHub
---

[Auth.js GitHub Provider Docs](https://authjs.dev/getting-started/providers/github)

**Required environment variables:**
- `AUTH_EE_GITHUB_CLIENT_ID`
- `AUTH_EE_GITHUB_CLIENT_SECRET`

Optional environment variables:
- `AUTH_EE_GITHUB_BASE_URL` - Base URL for GitHub Enterprise (defaults to https://github.com)

### GitLab
---

[Auth.js GitLab Provider Docs](https://authjs.dev/getting-started/providers/gitlab)

**Required environment variables:**
- `AUTH_EE_GITLAB_CLIENT_ID`
- `AUTH_EE_GITLAB_CLIENT_SECRET`

Optional environment variables:
- `AUTH_EE_GITLAB_BASE_URL` - Base URL for GitLab instance (defaults to https://gitlab.com)

### Google
---

[Auth.js Google Provider Docs](https://authjs.dev/getting-started/providers/google)

**Required environment variables:**
- `AUTH_EE_GOOGLE_CLIENT_ID`
- `AUTH_EE_GOOGLE_CLIENT_SECRET`

### Okta
---

[Auth.js Okta Provider Docs](https://authjs.dev/getting-started/providers/okta)

**Required environment variables:**
- `AUTH_EE_OKTA_CLIENT_ID`
- `AUTH_EE_OKTA_CLIENT_SECRET`
- `AUTH_EE_OKTA_ISSUER`

### Keycloak
---

[Auth.js Keycloak Provider Docs](https://authjs.dev/getting-started/providers/keycloak)

**Required environment variables:**
- `AUTH_EE_KEYCLOAK_CLIENT_ID`
- `AUTH_EE_KEYCLOAK_CLIENT_SECRET`
- `AUTH_EE_KEYCLOAK_ISSUER`

---

# Troubleshooting

- If you experience issues logging in, logging out, or accessing an organization you should have access to, try clearing your cookies & performing a full page refresh (`Cmd/Ctrl + Shift + R` on most browsers).
- Still not working? Reach out to us on our [discord](https://discord.com/invite/6Fhp27x7Pb) or [github discussions](https://github.com/sourcebot-dev/sourcebot/discussions)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ sidebarTitle: Declarative config

import ConfigSchema from '/snippets/schemas/v3/index.schema.mdx'

<Warning>
Declaratively defining `connections` is not available when [multi-tenancy](/self-hosting/more/tenancy) is enabled.
</Warning>

Some teams require Sourcebot to be configured via a file (where it can be stored in version control, run through CI/CD pipelines, etc.) instead of a web UI. For more information on configuring connections, see this [overview](/docs/connections/overview).


Expand Down
67 changes: 67 additions & 0 deletions docs/self-hosting/configuration/environment-variables.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Environment Variables
sidebarTitle: Environment Variables
---

<Note>This page provides a detailed reference of all environment variables supported by Sourcebot. If you're just looking to get up and running, we recommend starting with the [getting started](/self-hosting/overview) guide instead.</Note>

### Core Environment Variables
The following environment variables allow you to configure your Sourcebot deployment.

| Variable | Default | Description |
| :------- | :------ | :---------- |
| `AUTH_CREDENTIALS_LOGIN_ENABLED` | `true` | <p>Enables/disables authentication with basic credentials. Username and passwords are stored encrypted at rest within the postgres database. Checkout the [auth docs](/self-hosting/configuration/authentication) for more info</p> |
| `AUTH_EMAIL_CODE_LOGIN_ENABLED` | `false` | <p>Enables/disables authentication with a login code that's sent to a users email. `SMTP_CONNECTION_URL` and `EMAIL_FROM_ADDRESS` must also be set. Checkout the [auth docs](/self-hosting/configuration/authentication) for more info </p> |
| `AUTH_SECRET` | Automatically generated at startup if no value is provided. Generated using `openssl rand -base64 33` | <p>Used to validate login session cookies</p> |
| `AUTH_URL` | - | <p>URL of your Sourcebot deployment, e.g., `https://example.com` or `http://localhost:3000`.</p> |
| `CONFIG_PATH` | `-` | <p>The container relative path to the declerative configuration file. See [this doc](/self-hosting/configuration/declarative-config) for more info.</p> |
| `DATA_CACHE_DIR` | `$DATA_DIR/.sourcebot` | <p>The root data directory in which all data written to disk by Sourcebot will be located.</p> |
| `DATA_DIR` | `/data` | <p>The directory within the container to store all persistent data. Typically, this directory will be volume mapped such that data is persisted across container restarts (e.g., `docker run -v $(pwd):/data`)</p> |
| `DATABASE_DATA_DIR` | `$DATA_CACHE_DIR/db` | <p>The data directory for the default Postgres database.</p> |
| `DATABASE_URL` | `postgresql://postgres@ localhost:5432/sourcebot` | <p>Connection string of your Postgres database. By default, a Postgres database is automatically provisioned at startup within the container.</p><p>If you'd like to use a non-default schema, you can provide it as a parameter in the database url </p> |
| `EMAIL_FROM_ADDRESS` | `-` | <p>The email address that transactional emails will be sent from. See [this doc](/self-hosting/configuration/transactional-emails) for more info.</p> |
| `REDIS_DATA_DIR` | `$DATA_CACHE_DIR/redis` | <p>The data directory for the default Redis instance.</p> |
| `REDIS_URL` | `redis://localhost:6379` | <p>Connection string of your Redis instance. By default, a Redis database is automatically provisioned at startup within the container.</p> |
| `SHARD_MAX_MATCH_COUNT` | `10000` | <p>The maximum shard count per query</p> |
| `SMTP_CONNECTION_URL` | `-` | <p>The url to the SMTP service used for sending transactional emails. See [this doc](/self-hosting/configuration/transactional-emails) for more info.</p> |
| `SOURCEBOT_ENCRYPTION_KEY` | Automatically generated at startup if no value is provided. Generated using `openssl rand -base64 24` | <p>Used to encrypt connection secrets and generate API keys.</p> |
| `SOURCEBOT_LOG_LEVEL` | `info` | <p>The Sourcebot logging level. Valid values are `debug`, `info`, `warn`, `error`, in order of severity.</p> |
| `SOURCEBOT_TELEMETRY_DISABLED` | `false` | <p>Enables/disables telemetry collection in Sourcebot. See [this doc](/self-hosting/security/telemetry) for more info.</p> |
| `TOTAL_MAX_MATCH_COUNT` | `100000` | <p>The maximum number of matches per query</p> |
| `ZOEKT_MAX_WALL_TIME_MS` | `10000` | <p>The maximum real world duration (in milliseconds) per zoekt query</p> |

### Enterprise Environment Variables
| Variable | Default | Description |
| :------- | :------ | :---------- |
| `AUTH_EE_ATLASSIAN_BASE_URL` | `https://auth.atlassian.com` | <p>The base URL for Atlassian SSO authentication.</p> |
| `AUTH_EE_ATLASSIAN_CLIENT_ID` | `-` | <p>The client ID for Atlassian SSO authentication.</p> |
| `AUTH_EE_ATLASSIAN_CLIENT_SECRET` | `-` | <p>The client secret for Atlassian SSO authentication.</p> |
| `AUTH_EE_ENABLE_JIT_PROVISIONING` | `false` | <p>Enables/disables just-in-time user provisioning for SSO providers.</p> |
| `AUTH_EE_GITHUB_BASE_URL` | `https://github.com` | <p>The base URL for GitHub Enterprise SSO authentication.</p> |
| `AUTH_EE_GITHUB_CLIENT_ID` | `-` | <p>The client ID for GitHub Enterprise SSO authentication.</p> |
| `AUTH_EE_GITHUB_CLIENT_SECRET` | `-` | <p>The client secret for GitHub Enterprise SSO authentication.</p> |
| `AUTH_EE_GITLAB_BASE_URL` | `https://gitlab.com` | <p>The base URL for GitLab Enterprise SSO authentication.</p> |
| `AUTH_EE_GITLAB_CLIENT_ID` | `-` | <p>The client ID for GitLab Enterprise SSO authentication.</p> |
| `AUTH_EE_GITLAB_CLIENT_SECRET` | `-` | <p>The client secret for GitLab Enterprise SSO authentication.</p> |
| `AUTH_EE_GOOGLE_CLIENT_ID` | `-` | <p>The client ID for Google SSO authentication.</p> |
| `AUTH_EE_GOOGLE_CLIENT_SECRET` | `-` | <p>The client secret for Google SSO authentication.</p> |
| `AUTH_EE_KEYCLOAK_CLIENT_ID` | `-` | <p>The client ID for Keycloak SSO authentication.</p> |
| `AUTH_EE_KEYCLOAK_CLIENT_SECRET` | `-` | <p>The client secret for Keycloak SSO authentication.</p> |
| `AUTH_EE_KEYCLOAK_ISSUER` | `-` | <p>The issuer URL for Keycloak SSO authentication.</p> |
| `AUTH_EE_OKTA_CLIENT_ID` | `-` | <p>The client ID for Okta SSO authentication.</p> |
| `AUTH_EE_OKTA_CLIENT_SECRET` | `-` | <p>The client secret for Okta SSO authentication.</p> |
| `AUTH_EE_OKTA_ISSUER` | `-` | <p>The issuer URL for Okta SSO authentication.</p> |


### Review Agent Environment Variables
| Variable | Default | Description |
| :------- | :------ | :---------- |
| `GITHUB_APP_ID` | `-` | <p>The GitHub App ID used for review agent authentication.</p> |
| `GITHUB_APP_PRIVATE_KEY_PATH` | `-` | <p>The container relative path to the private key file for the GitHub App used by the review agent.</p> |
| `GITHUB_APP_WEBHOOK_SECRET` | `-` | <p>The webhook secret for the GitHub App used by the review agent.</p> |
| `OPENAI_API_KEY` | `-` | <p>The OpenAI API key used by the review agent.</p> |
| `REVIEW_AGENT_API_KEY` | `-` | <p>The Sourcebot API key used by the review agent.</p> |
| `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` | <p>Enables/disables automatic code reviews by the review agent.</p> |
| `REVIEW_AGENT_LOGGING_ENABLED` | `true` | <p>Enables/disables logging for the review agent. Logs are saved in `DATA_CACHE_DIR/review-agent`</p> |
| `REVIEW_AGENT_REVIEW_COMMAND` | `review` | <p>The command used to trigger a code review by the review agent.</p> |

Loading