mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
fixes
This commit is contained in:
parent
b0dc257b2a
commit
2d2d540d9b
6 changed files with 185 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ Sourcebot's built-in authentication system gates your deployment, and allows adm
|
||||||
<Card horizontal title="Authentication providers" icon="lock" href="/docs/configuration/auth/providers">
|
<Card horizontal title="Authentication providers" icon="lock" href="/docs/configuration/auth/providers">
|
||||||
Configure additional authentication providers for your deployment.
|
Configure additional authentication providers for your deployment.
|
||||||
</Card>
|
</Card>
|
||||||
<Card horizontal title="Inviting members" icon="user" href="/docs/configuration/auth/inviting-members">
|
<Card horizontal title="Access settings" icon="user" href="/docs/configuration/auth/access-settings">
|
||||||
Learn how to configure how members join your deployment.
|
Learn how to configure how members join your deployment.
|
||||||
</Card>
|
</Card>
|
||||||
<Card horizontal title="Roles and permissions" icon="shield" href="/docs/configuration/auth/roles-and-permissions">
|
<Card horizontal title="Roles and permissions" icon="shield" href="/docs/configuration/auth/roles-and-permissions">
|
||||||
|
|
|
||||||
|
|
@ -4273,6 +4273,89 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"apps": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "Defines a collection of apps that are available to Sourcebot.",
|
||||||
|
"items": {
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "AppConfig",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"type": "object",
|
||||||
|
"title": "GithubAppConfig",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "githubApp",
|
||||||
|
"description": "GitHub App Configuration"
|
||||||
|
},
|
||||||
|
"deploymentHostname": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "hostname",
|
||||||
|
"default": "github.com",
|
||||||
|
"description": "The hostname of the GitHub App deployment.",
|
||||||
|
"examples": [
|
||||||
|
"github.com",
|
||||||
|
"github.example.com"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The ID of the GitHub App."
|
||||||
|
},
|
||||||
|
"privateKey": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"secret": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the secret that contains the token."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"secret"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"env": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"env"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The private key of the GitHub App."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"privateKey"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"privateKeyPath"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,13 @@ export const fetchWithRetry = async <T>(
|
||||||
export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: PrismaClient, logger?: Logger): Promise<RepoAuthCredentials | undefined> => {
|
export const getAuthCredentialsForRepo = async (repo: RepoWithConnections, db: PrismaClient, logger?: Logger): Promise<RepoAuthCredentials | undefined> => {
|
||||||
// If we have github apps configured we assume that we must use them for github service auth
|
// If we have github apps configured we assume that we must use them for github service auth
|
||||||
if (repo.external_codeHostType === 'github' && hasEntitlement('github-app') && GithubAppManager.getInstance().appsConfigured()) {
|
if (repo.external_codeHostType === 'github' && hasEntitlement('github-app') && GithubAppManager.getInstance().appsConfigured()) {
|
||||||
const org = repo.displayName?.split('/')[0];
|
const owner = repo.displayName?.split('/')[0];
|
||||||
const deploymentHostname = new URL(repo.external_codeHostUrl).hostname;
|
const deploymentHostname = new URL(repo.external_codeHostUrl).hostname;
|
||||||
if (!org || !deploymentHostname) {
|
if (!owner || !deploymentHostname) {
|
||||||
throw new Error(`Failed to fetch GitHub App for repo ${repo.displayName}:Invalid repo displayName (${repo.displayName}) or deployment hostname (${deploymentHostname})`);
|
throw new Error(`Failed to fetch GitHub App for repo ${repo.displayName}:Invalid repo displayName (${repo.displayName}) or deployment hostname (${deploymentHostname})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = await GithubAppManager.getInstance().getInstallationToken(org, deploymentHostname);
|
const token = await GithubAppManager.getInstance().getInstallationToken(owner, deploymentHostname);
|
||||||
return {
|
return {
|
||||||
hostUrl: repo.external_codeHostUrl,
|
hostUrl: repo.external_codeHostUrl,
|
||||||
token,
|
token,
|
||||||
|
|
|
||||||
|
|
@ -4272,6 +4272,89 @@ const schema = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"apps": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "Defines a collection of apps that are available to Sourcebot.",
|
||||||
|
"items": {
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "AppConfig",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"type": "object",
|
||||||
|
"title": "GithubAppConfig",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "githubApp",
|
||||||
|
"description": "GitHub App Configuration"
|
||||||
|
},
|
||||||
|
"deploymentHostname": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "hostname",
|
||||||
|
"default": "github.com",
|
||||||
|
"description": "The hostname of the GitHub App deployment.",
|
||||||
|
"examples": [
|
||||||
|
"github.com",
|
||||||
|
"github.example.com"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The ID of the GitHub App."
|
||||||
|
},
|
||||||
|
"privateKey": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"secret": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the secret that contains the token."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"secret"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"env": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"env"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The private key of the GitHub App."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"privateKey"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"privateKeyPath"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ export type LanguageModel =
|
||||||
| OpenAICompatibleLanguageModel
|
| OpenAICompatibleLanguageModel
|
||||||
| OpenRouterLanguageModel
|
| OpenRouterLanguageModel
|
||||||
| XaiLanguageModel;
|
| XaiLanguageModel;
|
||||||
|
export type AppConfig = GithubAppConfig;
|
||||||
|
export type GithubAppConfig = {
|
||||||
|
[k: string]: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
export interface SourcebotConfig {
|
export interface SourcebotConfig {
|
||||||
$schema?: string;
|
$schema?: string;
|
||||||
|
|
@ -45,6 +49,10 @@ export interface SourcebotConfig {
|
||||||
* Defines a collection of language models that are available to Sourcebot.
|
* Defines a collection of language models that are available to Sourcebot.
|
||||||
*/
|
*/
|
||||||
models?: LanguageModel[];
|
models?: LanguageModel[];
|
||||||
|
/**
|
||||||
|
* Defines a collection of apps that are available to Sourcebot.
|
||||||
|
*/
|
||||||
|
apps?: AppConfig[];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Defines the global settings for Sourcebot.
|
* Defines the global settings for Sourcebot.
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,13 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "./languageModel.json"
|
"$ref": "./languageModel.json"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"apps": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "Defines a collection of apps that are available to Sourcebot.",
|
||||||
|
"items": {
|
||||||
|
"$ref": "./app.json"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue