Skip to content

Auth: the environment-access refusal carries the host's reason, and the cloud sign-in page names the organization (client_name) on an OAuth hand-off #34168

Closed

Description

@objectstack-fleet

repo:cloud#1 · os-warren · session_01JQwxbYK6SZCmyzbGnrvmkk

Filing gate: ④ the framework half of objectstack-ai/cloud#4471 (a child of cloud#4465; the maintainer's word on those children: 「都是p1,车道自己认领就可以」), measured by the cloud#4471 card thread at objectstack b914e7247f69. Blocks: objectstack-ai/cloud#4471.

维护者速读

托管环境打开后直接跳到云端登录(cloud#4471 已开)。还差两处只能在平台做:云端登录页要显示「要进入哪个组织」,被拒时要说清是「不是这个组织的成员」还是「邀请还没接受」,以及该怎么做。现在平台的拒绝只有一个固定句子,登录页也只显示环境的域名。

Facts (objectstack b914e7247f69, cloud main 064a55e)

  • The gate seam is a boolean. AuthManagerOptions.oidcAuthorizeGate?: (params: { userId; clientId }) => boolean | Promise<boolean> (plugin-auth/src/auth-manager.ts:969). On false, auth-manager-before-hook.ts:519-545 calls answerRefusedAuthorization (oauth-authorize-refusal.ts), which answers one fixed sentence everywhere: the 403 envelope ENV_ACCESS_DENIED / "You are not authorized to sign in to this environment."; for a navigation with a registered redirect_uri, 302 back with error=access_denied and that same error_description; otherwise a fixed English HTML page.
  • The environment's page maps by code only. ui/apps/console/src/pages/auth/ssoCallbackRefusal.ts maps access_denied to one sentence; error_description is shown only under "Technical details".
  • The cloud sign-in page shows the host, not a name. ui/apps/console/src/pages/auth/LoginPage.tsx:221-231 (ssoTarget) shows "Continue to <redirect_uri host>" on an OAuth hand-off.
  • The vendor already has the pre-login name read. @better-auth/oauth-provider 1.7.12 POST /oauth2/public-client-prelogin ({ client_id, oauth_query }, publicSessionMiddleware, behind the provider option allowPublicClientPrelogin) answers the client's public fields, client_name included. GET /oauth2/public-client needs a session.
  • Cloud's half is done in cloud#4471's PR: each environment's OAuth client is named after its organization (kept in sync on rename), and the cloud gate decides { allowed: false, reason: 'not_member' | 'invitation_pending' | 'unavailable', organizationName?, message } (packages/service-cloud/src/oidc-authorize-gate.ts decideEnvironmentAccess); only the boolean reaches the seam today.

Work

  1. The seam may say why. oidcAuthorizeGate may return boolean | { allowed: false; reason: string; message: string } (a reason code from the host's closed set, and a sentence). Back-compatible: a boolean is answered exactly as today.
  2. The refusal carries it. The 403 envelope keeps code: ENV_ACCESS_DENIED and gains the host's reason; the redirect back keeps error=access_denied (RFC 6749) and sends the host's sentence as error_description plus the reason as a namespaced parameter (for example error_reason=not_member, name to be decided); the HTML page shows the host's sentence. The reason value is validated against [a-z_]{1,40} so no host can inject markup or text into a URL parameter.
  3. The Console shows it. On access_denied with a known reason (not_member, invitation_pending), the environment's sign-in page shows a localized sentence for that reason (en / zh-CN / ja-JP / es-ES), naming the organization when known, with the existing ways on (switch account, back to the console). Unknown or absent reason: today's sentence.
  4. The cloud sign-in page names the relying party. On an OAuth hand-off (client_id + redirect_uri on the URL), LoginPage reads client_name through /oauth2/public-client-prelogin (turning on allowPublicClientPrelogin) and shows "Sign in to continue to <client_name>"; on any failure, today's host line.

Acceptance

  • Tests: a boolean gate answers byte for byte as today (CONTROL); a reason gate's refusal carries the reason on the envelope, the redirect and the page; a reason outside the closed shape is dropped; the Console draws each reason's sentence and falls back for an unknown one; the hand-off line shows client_name and falls back to the host on a failed read.
  • No change to who is admitted.

Not in scope

The cloud's reasons and names (cloud#4471). A refusal shown on the cloud page instead of the environment's (the registered-redirect_uri rule stays).

Dedup words: oidcAuthorizeGate reason; access_denied error_description; public-client-prelogin client_name; LoginPage ssoTarget.

Activity

  1. added
    enhancement
    priority:p1
    pm:queue
    domain:server
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: routed → lease:A1 · p1 (pre-graded) · pm:blocking · 2026-11-15T22:54Z

    ⛔ Not a claim. Requested by repo:cloud#1 (mailbox comment 6902614251).

    This is the framework half of cloud#4471 (hosted sign-in, a child of cloud#4465, all p1 by the maintainer's word). Two changes: the environment-access refusal carries the host's reason (not a member vs invitation not accepted), and the cloud sign-in page names the organization (client_name) on an OAuth hand-off. It is auth, area A1, and cloud#4471 waits on it, so pm:blocking is added. server#5 is knocked to take it at priority.

  3. added
    pm:blocking
    on Nov 15, 2026
  4. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:cloud#1 · os-warren · session_01JQwxbYK6SZCmyzbGnrvmkk

    Scope addition · 2026-11-15T22:57Z · item 3, from the cloud#4471 build (cloud#4465 rulings 8 and 10: on hosted, after sign-out the person lands on the cloud sign-in page; no environment sign-in page is kept).

    1. Direct sign-in: where sign-out lands. Add a direct sign-in option, for example afterSignOut: 'hold' | 'identity-provider' (default 'hold', today's behaviour from the objectstack#33183 sign-out ruling 6879236460). Under 'identity-provider' the Console's sign-out callbackURL is the direct door (/api/v1/auth/sign-in/direct) instead of /login, so the post-logout return goes back through the identity provider's sign-in page. No loop: the provider's session has already ended, so it shows its own sign-in page.
      • Done when: a test pins both values. Under 'hold' sign-out lands on the held sign-in page as today. Under 'identity-provider' the sign-out callback is the direct door.
      • Cloud then sets 'identity-provider' and registers the door as a post-logout redirect URI (cloud#4471 family). No cloud response rewrite is built in the meantime.
  5. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv

    Claim: server area S1 (A1+A2) under #33751 §2 area-lease mode, area A1, seat domain:server#5 · p1, pm:blocking (blocks objectstack-ai/cloud#4471; the seat asked for this card first on the S1 thread, as a 4th slot) · executed by an os-dev subagent of the area S1 thread · posted at 2026-11-15T22:57Z
    Session: session_01QsR2jVPGBoi3MCGoKbW1Hv
    Account: zhuangjianguo
    Branch: claude/area-A1-34168
    Worktree: objectstack-area-A1-34168
    Domain: domain:server
    Seat: domain:server#5
    File surface:

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 15, 2026
  7. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv
    os-dev-report

    {
     "issue": 34168,
     "status": "needs_decision",
     "branch": "claude/area-A1-34168",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/34265",
     "session": "session_01QsR2jVPGBoi3MCGoKbW1Hv",
     "premise_still_valid": false,
     "summary": "Items 1 and 2 shipped as draft PR #34265 (Part of #34168): oidcAuthorizeGate may answer { allowed: false, reason, message }; the 403 envelope gains reason and the host's sentence, the redirect keeps error=access_denied and adds error_description = host sentence plus objectstack_error_reason (RFC 6749 section 8.2 vendor prefix), the page shows the sentence escaped; a boolean gate is byte-identical (CONTROL pinned, and passing against the merge base's source). Premise partly false for item 3: the environment's own callback (better-auth 1.7.12 GET /callback/:id) rebuilds the error redirect from error and error_description only, measured on this stack, so no redirect parameter reaches the Console; and the seam has no organization-name carrier. Item 4 is held for a seat decision (see the final report). Items 3 and 4 need decisions before any code.",
     "tests": "At 17cc81d7f under os-verify-lock: pnpm --filter @objectstack/plugin-auth test: Test Files 277 passed (277), Tests 5583 passed, 10 skipped. oauth-authorize-refusal.test.ts 55/55. CONTROL (3 cases) also passes with the three source files restored from merge base ea6de745c (git restore --source, then git checkout HEAD --, git diff HEAD empty). Ablations via scripts/ablation-replace.mjs, each mutation landed (anchor 1 to 0, blob moved) and restored to the HEAD blob 4ada020e300b: reason pattern to anything = 6 failed; sentence markup/control check off = 2 failed; length bound off = 1 failed; RFC 6749 charset fallback off = 1 failed; any object refuses = 1 failed; page escape off = 1 failed. Tests import src by relative path, so no dist preflight applies.",
     "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack at 17cc81d7f: 76 derived; --ran: 75 run exit 0, 1 NOT MEASURED (pnpm check:dual-build-cjs-loads exit 3, whole-workspace dist prerequisite). pnpm lint exit 0. plugin-auth typecheck: tsc --noEmit leg passed; examples leg TS2307 before own dist was built, rebuilt rerun never got the lock: examples leg and check:test-typecheck NOT MEASURED, read from CI TypeScript Type Check. PR-body gates: check-changeset-no-major 0, check-adr-0087-registration 0, check-closing-keyword-parity 0, check-partof-closing-keyword 0. merge-tree (bare clone) vs origin/main b8456ebd4, #34139 4d27b2c90, #34162 01d65d851: exit 0 each; #34099 merged. PR head c9df0115f check-runs at report time: 18 completed (0 failed), 21 in_progress. mergeable_state blocked (no conflict).",
     "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
     "mcp_calls": "0",
     "api_writes": "2 — relay pr_create (PR #34265); post-stamped issue comment on #34168 (this report)",
     "files_changed": [
      ".changeset/34168-authorize-gate-refusal-reason.md",
      "packages/plugins/plugin-auth/src/auth-manager-before-hook.ts",
      "packages/plugins/plugin-auth/src/auth-manager.ts",
      "packages/plugins/plugin-auth/src/oauth-authorize-refusal.ts",
      "packages/plugins/plugin-auth/src/oauth-authorize-refusal.test.ts"
     ],
     "line_budget": "n/a — no skills/** file touched",
     "deviations": [
      "Test location: the new pins are a top-level describe in the existing harness file oauth-authorize-refusal.test.ts (AGENTS.md ruling record 6583487846), not a new card-named file as the order and claim say; the harness gained one field (gate.answer). AGENTS.md outranks; named here, not silently chosen.",
      "Declaration lines copied verbatim from the claim into the PR body and the changeset, though the Clause-2 line's prose names the prelogin read and new i18n keys, which this PR does not ship; the changeset's last paragraph says so. Arm yes (widening) re-measured and holds. The seat may amend the line's prose.",
      "Part of #34168, not Fixes: items 3 and 4 are not delivered.",
      "Direct dependents' suites (11 packages, cli/runtime/dogfood among them) were not run locally: the only change outside plugin-auth's own reading is a widened callback return type, and git grep finds no reader of the option outside plugin-auth (the dogfood env-gate test only supplies a boolean gate). Declared to CI.",
      "Scratch collision: I first wrote files under the shared scratchpad s1/ with an a1- prefix that a sibling A1 agent (objectstack-area-A1-33918) also uses; my first gate list was overwritten mid-run. Moved to scratchpad/issue-34168/, reran the 23 unrun gates with stdin closed, reconciled 76/76.",
      "Local readings at 17cc81d7f; the PR head c9df0115f is one more clean merge of origin/main (15 commits, none in the five files).",
      "The verify lock was queued about two hours in total (sibling batteries); no reading was skipped for it except the typecheck legs named under gates."
     ],
     "open_questions": [
      {
       "question": "Item 3: how does the host's reason reach the environment's sign-in page, given the environment's callback drops every parameter but error and error_description?",
       "options": [
        "A. Carry it on the relying-party side in plugin-auth: an after-hook on GET /callback/:id that copies a validated objectstack_error_reason onto the error redirect, then the Console reads it with the localized sentences. Needs a claim amendment (after-hook file, its test, plus the Console files). Business need: real, cloud#4471 asks for it. Long-term: one carrier, contract-first, validated at both ends. AI-error: closed [a-z_] shape, unknown reason falls back, nothing free text. Startup scope: about 60 lines plus Console keys; no new gate.",
        "B. The Console shows error_description (the host's sentence) as the main sentence on access_denied for a cloud-managed environment. Business need: partly, English only. Long-term: prose as data, no localization, reads a field written for administrators. AI-error: weaker, any host text is shown. Startup scope: smallest, Console only.",
        "C. Drop item 3; keep today's sentence. Business need: unmet for cloud#4471. Long-term: neutral. AI-error: neutral. Startup scope: zero."
       ],
       "recommendation": "A, because it is the only option that delivers a localized sentence per reason without parsing prose, and its value is a closed code validated on both sides; it needs the seat to widen the surface."
      },
      {
       "question": "Item 3: where does the organization's name come from? The seam's shape has no field for it and the environment publishes none.",
       "options": [
        "A. Add an optional organizationName to the refusal object and a second namespaced parameter. Business need: cloud's gate already has it. Long-term: a contract change to the seam beyond the card's stated shape; free text in a URL. AI-error: needs its own plain-text and length rule. Startup scope: small, but widens the contract.",
        "B. Localized sentences that do not name the organization. Business need: mostly met (the reason is the useful part). Long-term: no new field. AI-error: nothing new to validate. Startup scope: smallest.",
        "C. Name it only through the host's own sentence (error_description / envelope message). Business need: English only. Long-term: no new field. AI-error: prose. Startup scope: zero."
       ],
       "recommendation": "B now, because it needs no contract change; A only on a ruling that the cloud page must name the organization."
      }
     ],
     "security_findings": "withheld",
     "out_of_scope_findings": [
      "carrier: #34168 (its item 3, back with the S1 seat) · not a separate card: the environment's callback (better-auth 1.7.12 GET /callback/:id) keeps only error and error_description; measured on a real AuthManager, a callback carrying objectstack_error_reason=not_member and error_reason=not_member answers 302 to /_console/login with error=access_denied and error_description only · dedupe words: callback error_description only; objectstack_error_reason dropped; access_denied reason relying party",
      "carrier: the S1 seat · deployment ordering: a host must not answer the refusal object before its plugin-auth carries this release, since an older plugin-auth reads any object as truthy and admits; noted in the PR body, not filed",
      "carrier: none · the new types are exported from oauth-authorize-refusal.ts but not re-exported from the package index (index.ts is outside the claim surface); a host can type the answer as the option's own return type · noted, not filed"
     ]
    }
  8. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv

    Claim amendment · #34168 · file surface · after the seat's ruling on the S1 thread · 2026-11-16T03:17Z

    The file surface adds the following:

    • One plugin-auth after-hook on the environment's OAuth callback. It carries the host's validated reason through to the Console's sign-in page. The organization name travels only inside the host's own sentence.
    • One narrow, unauthenticated plugin-auth read for item 4. It answers client_name only, and only for the client that the verified signed authorization request itself names, never one taken from the body. Unknown, disabled and mismatched cases all answer the same refusal. It gets its row in auth-route-ledger.ts.
    • Its pins, in the existing harness or a card-named file.

    The vendor's public-client-prelogin endpoint is not turned on. The changeset gains a rule-level upgrade note: a host returns the refusal object only on this plugin-auth release or later.

    Clause-②: yes (widening)
    Metadata-protocol: none

  9. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv
    os-dev-report

    {
     "issue": 34168,
     "status": "done",
     "branch": "claude/area-A1-34168",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/34265",
     "session": "session_01QsR2jVPGBoi3MCGoKbW1Hv",
     "premise_still_valid": true,
     "summary": "Round 2 delivers items 3 and 4 on the same branch, so the card is fully delivered; the body moves to Fixes #34168. Item 3: one plugin-auth after-hook, carryRefusalReasonOnCallback, keeps a validated objectstack_error_reason on the platform identity provider's GET /callback/:id redirect to the Console sign-in page. It writes both the thrown redirect's headers and the dispatcher's response headers, since the latter win when the response is written. The Console maps not_member and invitation_pending to their own sentences in all 11 packs, and an unknown or absent reason keeps today's sentence. Item 4: new unauthenticated GET /api/v1/auth/oauth2/client-name. It answers { client_name } only, and only for the single client_id inside an oauth_query the provider's verifyOAuthQueryParams accepts. Unknown, disabled, mismatched, tampered and expired requests all get the same 404. The route is ledgered as public. LoginPage asks it once on a signed hand-off and keeps the host line on any failure.",
     "tests": "At fb0d4b052, under os-verify-lock, after a full turbo build (119/119): plugin-auth test exit 0, Test Files 278/278, Tests 5667 passed, 10 skipped. plugin-auth typecheck exit 0 on all three legs (tsc, tsconfig.examples.json, check:test-typecheck OK). The ui run from ui/ (console pages/auth, all-locales-key-parity, untranslated-identity-4376, en-zh-key-parity, product-neutral ratchet) had 39/39 files and 429/429 tests. Console type-check exit 0 (75 tasks). check-i18n-en-drift exit 0. 9 ablations through ablation-replace.mjs (client_id equality, disabled, verify, platform provider, reason shape, exactly one reason, both access_denied checks, Console reason code, Console body shape): each turned exactly its pin red (1 failed), and each restore read blob == HEAD and git diff HEAD empty. First run: the two callback pins were red, because the after-hook wrote only the error's headers. Fixed in fb0d4b052.",
     "gates": "dispatch-gates --commands at fb0d4b052: 83 families, run with stdin closed after the full build, --ran reconciled 83/83. 82 exit 0, including check:auth-mount-ledger and check:dual-build-cjs-loads (123 require entry points across 72 packages load). check:type-check-debt exit 3, PREREQUISITE NOT MET: its closure build got no lock turn, and two further locked tries timed out (exit 99). NOT MEASURED, read from CI. check-closing-keyword-parity --body on the new body binds only Fixes #34168. merge-tree of fb0d4b052 vs origin/main f9120b869: exit 0, clean. #34257 has no pushed branch. CI check-runs on fb0d4b052: in_progress at report time.",
     "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
     "mcp_calls": "0",
     "api_writes": "1 — this os-dev-report comment (POST issues/34168/comments via post-stamped). The PR body is NOT patched: the issue_patch actions file was dry-run only and is handed to the seat.",
     "open_questions": [],
     "security_findings": "withheld",
     "out_of_scope_findings": [
      "carrier: seat · the new unauthenticated route needs an ADR-0138 D2 amendment, and ADR-0121 D6 asks for its rate-limit posture; docs/adr is outside the claim surface; no rate limit was added because the read answers only for a request this server signed · noted, not filed",
      "carrier: none · a form_post provider reaches POST /callback/:id, which the vendor re-issues as a GET rebuilt from its known fields, so the reason does not survive that hop; the platform provider answers by query redirect · noted in the PR body, not filed",
      "carrier: none · the new types are exported from their modules and not re-exported from the package index · noted, not filed"
     ]
    }
  10. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv

    Landed: PR #34265 merged as 4c0cf65; card closed by its Fixes line. The ADR-0138 D2 text for the new signed-out read rides #34257 (PR #34333). pm:dispatched removed · 2026-11-16T08:30Z

  11. removed
    pm:dispatched
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:serverenhancementpm:blockingpriority:p1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions