Repository navigation
fix(auth): default-deny public self-signup on /api/access/request - #1274
Merged
Merged
Conversation
POST /api/access/request was unauthenticated and AUTO-WHITELISTED any submitted email (role `user`), so anyone who could reach the backend could self-enroll and then log in via email OTP — the email whitelist was non-authoritative against self-enrollment, despite the "request access" naming implying admin approval. Secure default: gate the endpoint behind PUBLIC_ACCESS_REQUESTS_ENABLED (env) / the `public_access_requests_enabled` system setting, default CLOSED. When off, the endpoint returns 403 and never whitelists. Operators who want frictionless `trinity:connect` CLI onboarding opt in explicitly. The gate runs before body parsing so a disabled instance never processes self-signup input. Product decision (recorded): keep frictionless auto-whitelist behind the flag rather than building a full admin-approval pending flow — minimal, non-breaking for opt-in users; a real pending flow can build on the existing #311 access_requests precedent later. Response wording no longer says "Access granted" (it isn't a per-request admin decision). Login-code requests for already-whitelisted emails (/api/auth/email/request) are unaffected. Default-deny blast radius is unchanged: a self-enrolled `user` owns no agents and cannot create any (#314), so even an opted-in instance grants only an empty session — but the whitelist is now the real gate by default. Tests: offline unit test for the gate (403 + no-whitelist when off; auto-whitelist when on; idempotent; 400 validation). Integration test_cli_access_request rewritten to cover the default-closed 403 and the operator-enabled path (toggled via the admin settings endpoint). Docs (architecture, cli-tool flow, .env.example) updated. Related to trinity-enterprise#10 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
vybe
approved these changes
Jun 19, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: P1 security fix (trinity-enterprise#10) — default-deny self-signup, fails secure (OFF→403), whitelist stays authoritative, no secrets. Docs + .env.example updated; 4 unit + CLI tests.
One non-blocking note: PUBLIC_ACCESS_REQUESTS_ENABLED isn't wired into docker-compose*.yml backend.environment, so that env lever is inert on prod-standalone — but the gate reads the DB system setting first (operators enable via PUT /api/settings), the secure default holds on deploy regardless, and this matches the existing SESSION_TAB_ENABLED settings-API-primary precedent. Approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/access/request(unauthenticated) auto-whitelisted any submitted email (roleuser), letting anyone who can reach the backend self-enroll and then log in via email OTP — so the email whitelist was not authoritative against self-enrollment, despite the "request access" naming implying admin approval.Fix — secure default: gate the endpoint behind
PUBLIC_ACCESS_REQUESTS_ENABLED(env) / thepublic_access_requests_enabledsystem setting, default CLOSED. When off →403, no whitelist write. The gate runs before body parsing so a disabled instance never processes self-signup input.Product decision (recorded per AC)
Keep frictionless auto-whitelist behind the flag rather than building a full admin-approval pending flow — minimal and non-breaking for opt-in (
trinity:connect) users. A real pending flow can later build on the existing #311access_requestsprecedent. Flipping the default off is a behavior change for anyone who relied on open self-signup — they set the flag to re-enable.Acceptance criteria
.env.example).Testing
tests/unit/test_ent10_access_request_gate.py(offline, 4 tests): 403 + no-whitelist when off; auto-whitelist (normalized email, roleuser) when on; idempotent; 400 validation once open. All pass.tests/test_cli_access_request.pyrewritten: default-closed403(+ asserts the email isn't whitelisted via the admin list), and an operator-enabled class that toggles the setting viaPUT /api/settings/{key}and restores it.lint_sys_modulesgreen.Related to trinity-enterprise#10