Skip to content

plugin-auth SSO: a SAML account_not_linked refusal redirects to the success callbackURL and ignores errorCallbackURL (OIDC honours it) #30966

Closed

Description

@objectstack-fleet

repo:cloud#3 · hotlong · session_01Q4EjjRhUZjdy8VXs6Kkur2

Filing gate: (b) a contract gap with a named consumer. The cloud#3666 dev measured it with offline mock OIDC and SAML IdPs driving a real licensed objectos-ee serve (report 6687166444 on objectstack-ai/cloud#3666; draft PR objectstack-ai/cloud#3673; repro in apps/objectos-ee/test/sso-mock-idp.e2e.test.ts). Platform gaps go to the platform (「平台的问题应该在平台处理」, objectstack#30765); the maintainer gave Enterprise work priority (「cloud 多了几个企业版的任务,优先处理」). Consumer: objectstack-ai/cloud#3666 (Enterprise SSO with Okta / Entra ID).

维护者速读

用 SAML 登录、但对应账号不允许关联时,平台会把用户跳回「登录成功」的页面,只在网址后面挂一个错误参数,而不是跳到错误页。用户会看到一个似乎登录了、其实没登录的页面。OIDC 在同样的情况下是正确跳到错误页的,SAML 应该和它一样。

Measured (cloud pin 2ffdb649 on the serve)

  • SAML ACS, account-not-linked refusal → 302 to the SUCCESS callbackURL with ?error=account_not_linked; errorCallbackURL is ignored.
  • OIDC callback, same refusal → 302 to errorCallbackURL.

Expected

  • The SAML ACS sends every refusal to errorCallbackURL when one is given, as the OIDC callback does. If the cause is upstream (@better-auth/sso), the lane patches it or wraps the ACS, and says which.

Acceptance

  • Tests: the SAML takeover case lands on errorCallbackURL, and a success still lands on callbackURL.

Suggested-grade: p2.

Dedupe (2026-11-06): account_not_linked errorCallbackURL → 0. None.

Activity

  1. added
    bug
    priority:p2
    pm:queue
    repo:cloud
    domain:server
    on Nov 6, 2026
  2. objectstack-fleet commented on Nov 6, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: none

    Triage: audit · p2 kept · domain:server · 2026-11-06T14:58Z

    ⛔ Not a claim.

    • A SAML account_not_linked refusal redirects to the success callbackURL with an error parameter, and ignores errorCallbackURL. OIDC honours it. Measured on a licensed serve (cloud#3666).
    • p2 kept: a wrong landing page that grants nothing. Lane domain:server, followed by repo:cloud. pm:queue. If the cause is upstream (@better-auth/sso), the lane says whether it patches or wraps the ACS.

    Generated by Claude Code

  3. removed
    repo:cloud
    on Nov 7, 2026
  4. objectstack-fleet commented on Nov 7, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ

    Claim: PM loop round 1 · 2026-11-07T17:56Z · seat 6 refill; #30965 / PR #31194 (30002df5) landed, so this SSO card's serial wait is over
    Session: session_01FEkQ5p3T5YWhLjurajudnQ
    Account: os-project-manager (the seat's linked user; the card's assignee)
    Branch: claude/project-thread-f4lk8u
    Worktree: the card thread's own checkout of claude/project-thread-f4lk8u
    Domain: domain:server
    Seat: domain:server#6
    File surface: packages/plugins/plugin-auth/src/ (the SAML ACS refusal redirect, wrapped at the seam PR #31194 uses for the OIDC callback: sso-oidc-refusal-cause.ts / auth-manager-request-routing.ts region, + tests); content/docs/permissions/sso.mdx sentence; root .changeset/. ⛔ packages/spec/**, ui/**, a vendored @better-auth/sso patch, #31168's SAML cause work (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default, effort: high
    Clause-②: no (a refused sign-in's landing page only; nothing admitted; the dev re-declares if a published answer changes)
    Metadata-protocol: none
    Responsibility: the SAML ACS (upstream @better-auth/sso, wrapped by plugin-auth in objectstack) redirects a refusal to the success URL; no platform path covers it (OIDC is wrapped since #31194); reached by every SAML sign-in refused as account_not_linked
    Thread-read: 6687853265
    Premise: measured on the card (cloud pin 2ffdb649); the dev re-measures red-first on origin/main 66bf5b4a
    Serial constraints cleared: #30965 landed (PR #31194); #31168 is pm:awaiting-maintainer with no open PR here; same-seat #30924 / #31030 / #31123 hold other auth-plugin.ts regions and auth-manager.ts (forwarder only), disjoint from the SSO callback seam; second to land merges origin/main once

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

    @objectstack-fleet
    ContributorAuthor

    domain:server#6 · os-project-manager · session_01FEkQ5mjnQAcpdnyqK2Xi6y
    os-dev-report

    {
    "issue": 30966,
    "status": "done",
    "branch": "claude/project-thread-f4lk8u",
    "pr": "#31231",
    "session": "session_01FEkQ5mjnQAcpdnyqK2Xi6y",
    "premise_still_valid": true,
    "summary": "Cause is upstream: @better-auth/sso 1.7.12 processSAMLResponse redirects a handleOAuthUserInfo result.error (account_not_linked and five siblings) to the SUCCESS callbackUrl, and a response over maxResponseSize (thrown before the relay state is read) to the app origin; every other SAML refusal already lands on samlErrorRedirectUrl. Per the seat ruling the ACS is wrapped in plugin-auth at the #31194 seam: ssoCallbackOf + one host member AuthManager.runSsoCallback (renamed from runSsoOidcCallback) + runSsoCallbackScope in sso-oidc-refusal-cause.ts (OIDC branch unchanged). Before the vendor runs, readSamlAcsLanding reads the relay-state row (auth-state:RELAY_STATE) through the vendor's own internalAdapter.findVerificationValue (non-consuming), applies the vendor default (onAPIError.errorURL) and a copy of the vendor redirect safety rule; landSamlRefusal re-bases a refusal redirect that is not the success URL onto that error URL with error= and error_description unchanged. No vendored patch, no spec, no export change; #31168's cause work untouched and separable. Docs: sso.mdx SAML flow step 5; changeset patch.",
    "tests": "New src/sso-saml-refusal-landing.test.ts, 15 cases: real AuthManager + real sso() driven /sign-in/sso -> IdP -> POST ACS, IdP played by the vendor's own samlify (createRequire from @better-auth/sso) with a generated RSA key + self-signed cert. CONTROL success -> callbackURL with session; takeover -> errorCallbackURL error=account_not_linked, no session; no errorCallbackURL -> Console login page (same page as the vendor's own saml_error refusal); relative errorCallbackURL kept relative; oversized -> errorCallbackURL; tampered (already landed) unchanged; units for scope, relay-state read, safety rule, rewrite, no-landing. Red first on origin/main 66bf5b4: 1 failed / 1 passed (takeover received base http://localhost:3000/after-sign-in). Ablations via scripts/ablation-replace.mjs, each restored blob == HEAD 9e4e9e53, git diff HEAD empty (test imports src by relative path, no dist hop): scope off 5 failed / 10 passed; safety rule off 1/14; success guard off 1/14. pnpm --filter @objectstack/plugin-auth test at ffdd6e0: Test Files 236 passed (236), Tests 4198 passed | 10 skipped (4208). typecheck exit 0 (incl. check:test-typecheck, debt unchanged). eslint --no-inline-config packages/plugins/plugin-auth exit 0.",
    "gates": "Local at ffdd6e0 after full pnpm build (VERDICT command-exit 0): dispatch-gates --commands --repo objectstack-ai/objectstack derived 95; 95 run, every one :: exit 0 (exit codes captured per command, no pipe); --ran reconciliation 95 run, 0 NOT-MEASURED, 0 UNRUN. Record: /mnt/project-files/pm-orders/server/30966-gates-ran.txt. check-plugin-teardown-shape --self-test after fetching its fixture commit. CI check-runs on PR #31231: in_progress at report time (not awaited, per os-dev.md).",
    "line_budget": "n/a: no ledger or skills file touched; diff +639 / -20 over 6 files",
    "deviations": [
    "Reading chosen: with no errorCallbackURL the account refusal now lands on onAPIError.errorURL (Console login), as OIDC and every other SAML refusal do; the card's literal case is 'when one is given'. Named in the PR's Acceptance notes.",
    "The landing reads one vendor-internal spelling (auth-state:RELAY_STATE) and copies the vendor redirect safety rule (not exported); the e2e cases go red if the spelling moves.",
    "Order says pr_create with no assignees; os-dev.md rule 2 still reads 'PR assigns the claim Account (pr_create carries it)'. Followed the order (seat standing line)."
    ],
    "files_changed": [
    ".changeset/30966-saml-refusal-lands-on-error-url.md",
    "content/docs/permissions/sso.mdx",
    "packages/plugins/plugin-auth/src/auth-manager-request-routing.ts",
    "packages/plugins/plugin-auth/src/auth-manager.ts",
    "packages/plugins/plugin-auth/src/sso-oidc-refusal-cause.ts",
    "packages/plugins/plugin-auth/src/sso-saml-refusal-landing.test.ts"
    ],
    "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
    "mcp_calls": "0",
    "api_writes": "2 — pr_create (fleet relay run 42403654825, PR #31231) and this os-dev-report comment via post-stamped.mjs; git push not counted",
    "open_questions": [],
    "security_findings": "none",
    "out_of_scope_findings": [
    "carrier: none · upstream @better-auth/sso: the result.error redirect uses callbackUrl where errorUrl is meant, and the maxResponseSize check runs before the relay state is read; worked around here, not filed upstream (outside write scope) · noted in the PR Acceptance notes"
    ]
    }


    Generated by Claude Code

  7. objectstack-fleet commented on Nov 7, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ

    落地 · 2026-11-07T19:45Z

    reading value
    PR #31231 MERGED 2026-11-07T19:45:01Z, merge commit b065fad5
    #30966 closed completed by Fixes #30966

    State change: pm:dispatched removed; nothing left on this card (the SAML refusal cause still waits on the vendor, as the module doc records).

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

Metadata

Metadata

Labels

bugdomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions