Skip to content

fix: dogfood workflow + auth bug allowing cross-org OAuth#536

Merged
buremba merged 3 commits into
mainfrom
fix/atlas-workflow-secret-name
May 5, 2026
Merged

fix: dogfood workflow + auth bug allowing cross-org OAuth#536
buremba merged 3 commits into
mainfrom
fix/atlas-workflow-secret-name

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 4, 2026

Two fixes bundled:

1. Workflow secret naming (originally #533 follow-up)

  • Switched from invented secrets.LOBU_DOGFOOD_ANTHROPIC_API_KEY to the existing ANTHROPIC_API_KEY (used by issue-triage.yml / claude.yml).
  • Pinned --org atlas on dry-run + apply so the workflow targets Atlas regardless of the LOBU_TOKEN's default context.
  • LOBU_TOKEN repo secret is set; it's currently a buremba-scoped token because the CLI couldn't mint cross-org. After fix Kubernetes Integration #2 below ships it'll work, but the dogfood needs an atlas-scoped token specifically — easiest is to mint it from the web UI on the atlas org.

2. lobu token create --org X bug (the real fix)

Found while bootstrapping the dogfood: minting a PAT for any org other than the user's OAuth-bound one returns 403 Token organization does not match URL organization. mcpAuth strict-matched the URL slug against every bearer's bound org.

PATs intentionally org-scoped (correct — keep strict). OAuth bearers bind to whichever org the user picked at consent time but users typically have memberships in many orgs, and the membership check at multi-tenant.ts:379 was already the real authorization gate.

Fix: keep strict for PATs; fall through to the URL slug for OAuth and let the membership check decide. lobu token create --org X now works from any active OAuth session (assuming the user has admin role in X).

Tests

  • Existing PAT-cross-org-rejection test unchanged → still 403, asserts strict PAT scoping.
  • New OAuth-cross-org-with-membership test → 200.
  • New OAuth-cross-org-without-membership test → 403 not a member.
  • bun run typecheck, bun run format:check clean.

The earlier dogfood PR invented LOBU_DOGFOOD_ANTHROPIC_API_KEY out of
nothing. The repo already has ANTHROPIC_API_KEY (used by issue-triage,
claude.yml). Use that one instead.

Also pin --org atlas explicitly so the workflow targets the Atlas org
regardless of what the LOBU_TOKEN's default context is set to. The
example dir lives under examples/atlas and its memory.owletto.org is
'atlas', so the apply target should match.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the triage:needs-human Triage agent escalated for human review label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Triage decision: needs-human

Reasons:

  • Changed file .github/workflows/lobu-apply-atlas.yml is under .github/workflows/ (infrastructure path)
  • Infrastructure changes require human review due to blast radius

Next: awaiting manual review and merge by assigned reviewer

Discovered while bootstrapping #533's dogfood workflow: 'lobu token
create --org atlas' from a buremba-bound CLI session failed with
'Token organization does not match URL organization', making it
impossible to mint a PAT for any org other than the one the user
happened to OAuth into via 'lobu login'.

Root cause: mcpAuth strict-matched the URL org slug against the
bearer's bound org for every token type. PATs SHOULD be strict — a
PAT minted for org A must never be usable against org B even if the
owner has membership in both. OAuth bearers shouldn't — they bind to
one org at consent time but the user typically has memberships in
many, and the membership check immediately below was already the real
authorization gate.

Fix: keep the strict match for PATs; fall through to the URL slug for
OAuth and let the membership check decide. The bootstrap path now
works ('lobu token create --org X' from any active OAuth session),
without weakening PAT scoping.

Tests: 'should reject org-bound PAT on a different organization
route' still asserts the strict PAT behavior (no behavior change).
Two new tests cover the OAuth path: cross-org with membership ->
allowed; cross-org without membership -> 403 'not a member'.
@buremba buremba changed the title fix: dogfood workflow uses real ANTHROPIC_API_KEY + pins --org atlas fix: dogfood workflow + auth bug allowing cross-org OAuth May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Triage decision: needs-human

Reasons:

  • Changed file .github/workflows/lobu-apply-atlas.yml is under .github/workflows/ (infrastructure path)
  • Infrastructure changes require human review due to blast radius

Next: awaiting manual review and merge by assigned reviewer

Two CI follow-ups:

1. The cross-org OAuth test was asserting status === 200, but reaching
   200 requires the full MCP initialize+notifications/initialized
   handshake; tools/list without a session returns 400 even when auth
   passes. The whole point of the test is to prove the auth gate no
   longer 403s on cross-org OAuth — assert that explicitly instead.

2. The dogfood apply job dies with 'Missing 1 required secret:
   *$ANTHROPIC_API_KEY' because the repo doesn't have an
   ANTHROPIC_API_KEY secret yet (issue-triage.yml references it but
   never had it set; secrets that don't exist evaluate to empty in
   Actions). Extend the existing skip-if-no-token gate to also skip
   when ANTHROPIC_API_KEY is empty, with the same exit-0 semantics.
   Once the secret is added the apply will run automatically.
@buremba buremba merged commit feae13a into main May 5, 2026
17 checks passed
@buremba buremba deleted the fix/atlas-workflow-secret-name branch May 5, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:needs-human Triage agent escalated for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes Integration

2 participants