Skip to content

Commit 0623f13

Browse files
committed
change forceEnableAnonymousAccess to be an env var
1 parent 5abadc1 commit 0623f13

File tree

9 files changed

+8
-41
lines changed

9 files changed

+8
-41
lines changed

docs/docs/configuration/auth/access-settings.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ There are various settings to control how users access your Sourcebot deployment
1111

1212
By default, your Sourcebot deployment is gated with a login page. If you'd like users to access the deployment anonymously, you can enable anonymous access.
1313

14-
This can be enabled by navigating to **Settings -> Access** or by setting the `forceEnableAnonymousAccess` setting in your configuration file.
14+
This can be enabled by navigating to **Settings -> Access** or by setting the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable.
1515

1616
# Member Approval
1717

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363
"type": "number",
6464
"description": "The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.",
6565
"minimum": 1
66-
},
67-
"forceEnableAnonymousAccess": {
68-
"type": "boolean",
69-
"description": "Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled."
7066
}
7167
},
7268
"additionalProperties": false
@@ -176,10 +172,6 @@
176172
"type": "number",
177173
"description": "The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.",
178174
"minimum": 1
179-
},
180-
"forceEnableAnonymousAccess": {
181-
"type": "boolean",
182-
"description": "Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled."
183175
}
184176
},
185177
"additionalProperties": false

packages/backend/src/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ export const DEFAULT_SETTINGS: Settings = {
1414
maxRepoIndexingJobConcurrency: 8,
1515
maxRepoGarbageCollectionJobConcurrency: 8,
1616
repoGarbageCollectionGracePeriodMs: 10 * 1000, // 10 seconds
17-
repoIndexTimeoutMs: 1000 * 60 * 60 * 2, // 2 hours
18-
forceEnableAnonymousAccess: false,
17+
repoIndexTimeoutMs: 1000 * 60 * 60 * 2 // 2 hours
1918
}

packages/schemas/src/v3/index.schema.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ const schema = {
6262
"type": "number",
6363
"description": "The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.",
6464
"minimum": 1
65-
},
66-
"forceEnableAnonymousAccess": {
67-
"type": "boolean",
68-
"description": "Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled."
6965
}
7066
},
7167
"additionalProperties": false
@@ -175,10 +171,6 @@ const schema = {
175171
"type": "number",
176172
"description": "The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.",
177173
"minimum": 1
178-
},
179-
"forceEnableAnonymousAccess": {
180-
"type": "boolean",
181-
"description": "Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled."
182174
}
183175
},
184176
"additionalProperties": false

packages/schemas/src/v3/index.type.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ export interface Settings {
7979
* The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.
8080
*/
8181
repoIndexTimeoutMs?: number;
82-
/**
83-
* Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled.
84-
*/
85-
forceEnableAnonymousAccess?: boolean;
8682
}
8783
/**
8884
* Search context

packages/web/src/app/components/organizationAccessSettings.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import { getOrgFromDomain } from "@/data/org"
55
import { getOrgMetadata } from "@/types"
66
import { headers } from "next/headers"
77
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants"
8-
import { hasEntitlement, loadConfig } from "@sourcebot/shared"
8+
import { hasEntitlement } from "@sourcebot/shared"
99
import { env } from "@/env.mjs"
10-
import { createLogger } from "@sourcebot/logger";
11-
12-
const logger = createLogger("OrganizationAccessSettings");
1310

1411
export async function OrganizationAccessSettings() {
1512
const org = await getOrgFromDomain(SINGLE_TENANT_ORG_DOMAIN);
@@ -26,13 +23,7 @@ export async function OrganizationAccessSettings() {
2623

2724
const hasAnonymousAccessEntitlement = hasEntitlement("anonymous-access");
2825

29-
let forceEnableAnonymousAccess = false;
30-
if (env.CONFIG_PATH) {
31-
const config = await loadConfig(env.CONFIG_PATH);
32-
forceEnableAnonymousAccess = config.settings?.forceEnableAnonymousAccess ?? false;
33-
} else {
34-
logger.warn("CONFIG_PATH is not set, so forceEnableAnonymousAccess will be false");
35-
}
26+
const forceEnableAnonymousAccess = env.FORCE_ENABLE_ANONYMOUS_ACCESS === 'true';
3627

3728
return (
3829
<div className="space-y-6">

packages/web/src/env.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const env = createEnv({
8080

8181
// Misc UI flags
8282
SECURITY_CARD_ENABLED: booleanSchema.default('false'),
83+
FORCE_ENABLE_ANONYMOUS_ACCESS: booleanSchema.default('false'),
8384

8485
// EE License
8586
SOURCEBOT_EE_LICENSE_KEY: z.string().optional(),

packages/web/src/initialize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ const syncConnections = async (connections?: { [key: string]: ConnectionConfig }
106106
const syncDeclarativeConfig = async (configPath: string) => {
107107
const config = await loadConfig(configPath);
108108

109-
if (config.settings?.forceEnableAnonymousAccess) {
109+
if (env.FORCE_ENABLE_ANONYMOUS_ACCESS === 'true') {
110110
const hasAnonymousAccessEntitlement = hasEntitlement("anonymous-access");
111111
if (!hasAnonymousAccessEntitlement) {
112-
logger.warn(`forceEnableAnonymousAccess is set to true but anonymous access entitlement is not available. Setting will be ignored.`);
112+
logger.warn(`FORCE_ENABLE_ANONYMOUS_ACCESS env var is set to true but anonymous access entitlement is not available. Setting will be ignored.`);
113113
} else {
114114
const org = await getOrgFromDomain(SINGLE_TENANT_ORG_DOMAIN);
115115
if (org) {
@@ -123,7 +123,7 @@ const syncDeclarativeConfig = async (configPath: string) => {
123123
}
124124
},
125125
});
126-
logger.info(`Anonymous access enabled via forceEnableAnonymousAccess setting`);
126+
logger.info(`Anonymous access enabled via FORCE_ENABLE_ANONYMOUS_ACCESS environment variable`);
127127
}
128128
}
129129
}

schemas/v3/index.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@
6161
"type": "number",
6262
"description": "The timeout (in milliseconds) for a repo indexing to timeout. Defaults to 2 hours.",
6363
"minimum": 1
64-
},
65-
"forceEnableAnonymousAccess": {
66-
"type": "boolean",
67-
"description": "Force enable anonymous access. When set to true, anonymous access will be enabled and the UI toggle will be disabled."
6864
}
6965
},
7066
"additionalProperties": false

0 commit comments

Comments
 (0)