Repository navigation
docs(embed): look up the sub-org on the server in the session example - #27
Merged
Merged
Conversation
The Step 1 example read the sub-org id from the request body, and the Step 2 frontend sent currentUser.subOrgId. Copied as-is, that lets a signed-in customer change the id in their browser and get a session for another customer's sub-org. The public SDK guide (auth-tenancy) already says not to accept an org id from the browser as authority. The backend now resolves the sub-org from the signed-in user, and the frontend sends no id. Also add a User-Agent header (requests without one can be blocked before reaching the API) and short notes on always sending organization_id, multi-tenant users, and session expiry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
behobu
requested review from
Credgate,
andrewc-monad,
brenth-monad,
mattj-monad and
saikapuluru99
as code owners
December 1, 2026 21:35
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
The session example in
USAGE.mdread the sub-org id from the request body (Step 1), and the frontend sentcurrentUser.subOrgId(Step 2). Copied as-is, a signed-in customer could change that id in their browser and get a session for another customer's sub-org. The public SDK guide (/docs/sdks/embed/auth-tenancy) already says not to accept an org id from the browser as authority, so the package docs contradicted it.getSignedInUser→lookUpMonadSubOrg), returning 401/404 when it can't, and sends aUser-Agentheader (requests without one can be blocked before they reach the API).organization_id, users who belong to several tenants (check membership server-side before minting), and session expiry (keepexpires_atand remount before it)..changeset/server-side-sub-org-lookup.md: patch bump, so the correctedUSAGE.mdreaches npm.Docs only; no code or exported API changes. The
onErrorrow is unchanged; the form doesn't yet report Test/Save failures to it, which is tracked as ENG-12581 and should be fixed in the form rather than in these docs.Related: ENG-12581 (form doesn't report expired sessions via
onError), ENG-12582 (/v3/sessionsdoesn't checkorganization_idagainst the key's access).Test plan
pnpm format:check,pnpm typecheck,pnpm test(6/6) passpnpm lint: 0 errors (5 existing warnings, none in changed files)organization_idgets the key's full access🤖 Generated with Claude Code