Skip to content

Commit d7c88f1

Browse files
committed
fix(config): address review findings
1 parent ff421d8 commit d7c88f1

7 files changed

Lines changed: 84 additions & 3 deletions

File tree

‎apps/docs/content/docs/chat/mailer.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Sim Mailer gives an enabled workspace an email address. Send or forward a messag
1111

1212
A workspace **Admin** configures the inbox. On Sim Cloud, availability follows the workspace's Max or Enterprise plan and active billing, rather than the sender's individual plan.
1313

14-
On self-hosted deployments, availability depends on configured Chat and email services. `INBOX_ENABLED` or billing-disabled configuration can allow access, but the required Chat service key must still be configured. See [self-hosted environment variables](/platform/self-hosting/environment-variables).
14+
On self-hosted deployments without billing, the inbox is on by default. Set `INBOX_ENABLED=false` to turn it off; that closes it on the server and removes it from the interface. It still needs the Chat service key and email services configured to work. See [self-hosted environment variables](/platform/self-hosting/environment-variables).
1515

1616
Members keep their own workspace permissions when submitting email tasks. An allowed external email sender can submit read-only tasks; allowlisting does not grant workspace membership, workflow execution, mutation access, or raw-secret access.
1717

‎apps/docs/content/docs/platform/self-hosting/authentication.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ In the `closed` modes, existing accounts can still sign in, including to accept
8282
| `EMAIL_PASSWORD_SIGNUP_ENABLED=false` (or `NEXT_PUBLIC_EMAIL_PASSWORD_SIGNUP_ENABLED=false`) | `no-email` |
8383
| `DISABLE_REGISTRATION=true` with `EMAIL_PASSWORD_SIGNUP_ENABLED=false` | `closed-no-email` |
8484

85+
`NEXT_PUBLIC_EMAIL_PASSWORD_SIGNUP_ENABLED=false` used to only hide the email form in the browser. It now also turns off email/password and email OTP sign-in on the server for every account, existing ones included; set `REGISTRATION_MODE` explicitly to choose the behavior you want.
86+
8587
The other sign-in controls:
8688

8789
| Variable | Effect |

‎apps/sim/app/(landing)/components/auth-modal/auth-modal.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ export function AuthModal({ children, defaultView = 'login', source }: AuthModal
8787
const ssoEnabled = isSsoEnabled
8888
const {
8989
selfServeRegistrationClosed: registrationDisabled,
90-
emailPasswordAuthEnabled: emailEnabled,
90+
emailSignupAllowed,
91+
emailPasswordAuthEnabled,
9192
} = getRegistrationPolicy(useDeploymentShape().registrationMode ?? 'open')
9293

9394
/**
9495
* Signup is unavailable when registration is disabled, so the shown view is
9596
* clamped to login rather than mirrored into state through an effect.
9697
*/
9798
const effectiveView: AuthView = view === 'signup' && registrationDisabled ? 'login' : view
99+
const emailEnabled = effectiveView === 'signup' ? emailSignupAllowed : emailPasswordAuthEnabled
98100

99101
/**
100102
* Tracks whether the visitor still wants the modal open. Cleared on dismiss so a

‎apps/sim/app/_shell/public-env-script.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export function publicEnvHtmlAttributes(): Record<string, string> {
4949
* shape, which the browser reads instead of rebuilding deployment configuration from
5050
* `NEXT_PUBLIC_*` twins. Rides on `<html>` for the same ordering reason as
5151
* {@link publicEnvHtmlAttributes}; see `@/lib/core/config/deployment-projection`.
52+
*
53+
* Every field is visible to any visitor, signed in or not, so the shape must never
54+
* carry a secret, URL, or identifier (`deployment-shape.test.ts` guards this). It
55+
* relies on the same dynamic-root guarantee as {@link PUBLIC_ENV_ATTRIBUTE}: a
56+
* prerendered page would carry build-time values instead of the running config.
5257
*/
5358
export function deploymentShapeHtmlAttributes(): Record<string, string> {
5459
return { [DEPLOYMENT_SHAPE_ATTRIBUTE]: JSON.stringify(resolveDeploymentShape()) }

‎apps/sim/content/library/govern-ai-agents-multiple-teams-enterprise-workspace/index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Sim's [Apache 2.0 core](https://github.com/simstudioai/sim) can run on customer-
288288

289289
Local models are a self-hosting capability rather than an Enterprise plan entitlement: any [self-hosted Sim deployment](https://docs.sim.ai/platform/self-hosting) can connect to Ollama, vLLM, LM Studio, or LiteLLM through the supported model endpoints.
290290

291-
Sim's [self-hosted Enterprise documentation](https://docs.sim.ai/platform/enterprise#self-hosted-setup) states that self-hosted deployments unlock Enterprise features through environment configuration instead of billing. Setting `ENTERPRISE_ENABLED=true` and `NEXT_PUBLIC_ENTERPRISE_ENABLED=true` enables the full feature set, and per-feature flags can enable or disable individual capabilities. Configuration does not change the license terms: production use of these features still requires an active Sim Enterprise subscription. This is evidence of the no-lock-in architecture: access to the software's governance capabilities does not disappear merely because an organization moves from Sim Cloud to infrastructure it controls.
291+
Sim's [self-hosted Enterprise documentation](https://docs.sim.ai/platform/enterprise#self-hosted-setup) states that self-hosted deployments unlock Enterprise features through environment configuration instead of billing. Setting the server variable `ENTERPRISE_ENABLED=true` enables the full feature set, and per-feature flags can enable or disable individual capabilities. Configuration does not change the license terms: production use of these features still requires an active Sim Enterprise subscription. This is evidence of the no-lock-in architecture: access to the software's governance capabilities does not disappear merely because an organization moves from Sim Cloud to infrastructure it controls.
292292

293293
Most Enterprise features read settings from the organization that owns a workspace. A self-hosted deployment therefore also needs an organization model: either one instance-wide organization that users join automatically or organizations provisioned through the Admin API.
294294

‎apps/sim/lib/core/config/deployment-shape.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { REGISTRATION_MODES } from '@sim/deployment-config/registration'
12
import { resetEnvFlagsMock, setEnvFlags } from '@sim/testing'
23
import { afterEach, describe, expect, it } from 'vitest'
34
import {
@@ -18,6 +19,59 @@ describe('resolveDeploymentShape', () => {
1819
})
1920
})
2021

22+
/** Enum-valued fields the shape may carry, each with every value it may take. */
23+
const ENUM_FIELDS: Record<string, readonly string[]> = {
24+
registrationMode: REGISTRATION_MODES,
25+
}
26+
27+
/** The only nested objects the shape may carry; every value inside one must be a boolean. */
28+
const BOOLEAN_MAP_FIELDS = new Set(['features'])
29+
30+
/**
31+
* Every value in the shape that is neither a boolean, a known enum value, nor a
32+
* boolean inside an allowed map, as `path: value`. The shape is serialized onto
33+
* `<html>` for every visitor, so anything else (a URL, a key, an id) is a leak.
34+
*/
35+
function nonPublicValues(shape: Record<string, unknown>): string[] {
36+
const findings: string[] = []
37+
for (const [key, value] of Object.entries(shape)) {
38+
if (typeof value === 'boolean') continue
39+
if (key in ENUM_FIELDS) {
40+
if (!ENUM_FIELDS[key].includes(value as string)) findings.push(`${key}: ${String(value)}`)
41+
continue
42+
}
43+
if (
44+
BOOLEAN_MAP_FIELDS.has(key) &&
45+
value &&
46+
typeof value === 'object' &&
47+
!Array.isArray(value)
48+
) {
49+
for (const [nestedKey, nestedValue] of Object.entries(value)) {
50+
if (typeof nestedValue !== 'boolean') {
51+
findings.push(`${key}.${nestedKey}: ${JSON.stringify(nestedValue)}`)
52+
}
53+
}
54+
continue
55+
}
56+
findings.push(`${key}: ${JSON.stringify(value)}`)
57+
}
58+
return findings
59+
}
60+
61+
describe('resolveDeploymentShape as a public surface', () => {
62+
it.each([
63+
['self-hosted defaults', {}],
64+
[
65+
'a hosted deployment with billing and a restricted mode',
66+
{ isHosted: true, isBillingEnabled: true, registrationMode: 'closed-no-email' as const },
67+
],
68+
])('carries only booleans and known enum values for %s', (_label, flags) => {
69+
setEnvFlags(flags)
70+
71+
expect(nonPublicValues({ ...resolveDeploymentShape() })).toEqual([])
72+
})
73+
})
74+
2175
describe('getDeploymentShape on the server', () => {
2276
it('answers from the env flags and ignores seeding, which is browser-only', () => {
2377
seedDeploymentShape({ ...resolveDeploymentShape(), hosted: true })

‎apps/sim/lib/core/config/registration.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ describe('resolveRegistrationMode', () => {
4141
expect(resolve({ mode: 'true' }).mode).toBe('closed')
4242
})
4343

44+
it('accepts a mode in any case without reporting it invalid', () => {
45+
expect(resolve({ mode: 'CLOSED' })).toEqual({ mode: 'closed', warnings: [] })
46+
})
47+
48+
it('accepts a mode with surrounding whitespace', () => {
49+
expect(resolve({ mode: ' no-email ' })).toEqual({ mode: 'no-email', warnings: [] })
50+
})
51+
52+
describe('deprecated values written in another case or padded', () => {
53+
it('reads DISABLE_REGISTRATION=TRUE as closed', () => {
54+
expect(resolve({ legacy: { disableRegistration: 'TRUE' } }).mode).toBe('closed')
55+
})
56+
57+
it('reads EMAIL_PASSWORD_SIGNUP_ENABLED=" FALSE " as no-email', () => {
58+
expect(resolve({ legacy: { emailPasswordSignupEnabled: ' FALSE ' } }).mode).toBe('no-email')
59+
})
60+
})
61+
4462
describe('deprecated variables alone', () => {
4563
it('maps DISABLE_REGISTRATION to closed', () => {
4664
const resolved = resolve({ legacy: { disableRegistration: 'true' } })

0 commit comments

Comments
 (0)