fix(marketplace): send Bearer token on cloud-connection install/probe#1486
Merged
Conversation
The in-environment marketplace install and installed-state probe call the same-origin `/api/v1/cloud-connection/install` and `/installation` routes with raw `fetch()` + `credentials: 'include'` and no Authorization header. objectui authenticates with a Bearer token (better-auth, stored in localStorage and normally injected by `createAuthenticatedFetch`). On a tenant runtime the env session cookie is not reliably presented after platform SSO, so cookie-only auth makes the server's `resolveEnvSession` find no session and return 401 `unauthenticated` / "Sign in to this environment." even though the user is signed in. Inject the Bearer token (which the server's `getSession` accepts — verified: the same route returns 200 when given the session token as a Bearer) on both cloud-connection calls. `credentials: 'include'` is kept so the cookie still rides along when present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Symptom
After SSO into a tenant environment, opening a marketplace package or clicking Install fails:
{"success":false,"error":{"code":"unauthenticated","message":"Sign in to this environment."}}…even though the user is signed in (valid, non-expired session in the env DB).
Root cause
objectui authenticates with a Bearer token (better-auth; token in localStorage, normally injected on every
/api/call bycreateAuthenticatedFetch/createBearerFetch). The in-environment marketplace calls inmarketplaceApi.tsuse rawfetch()withcredentials: 'include'and noAuthorizationheader, so they bypass that wrapper and rely on the session cookie alone.On a tenant runtime the env session cookie is not reliably presented after platform SSO, so the server route's
resolveEnvSession(apps/objectos/cloud-runtime-plugins.ts) finds no session → 401.Verified: the same server route returns
200when the session is supplied asAuthorization: Bearer <token>— so the server already accepts the Bearer; the client just wasn't sending it.Fix
Inject the Bearer token (from
@object-ui/authTokenStorage) on the two same-origin cloud-connection calls —/installand/installation— via a smallwithEnvAuth()helper.credentials: 'include'is kept so the cookie still rides along when present.Test plan
/api/v1/cloud-connection/installationreturns 200 withAuthorization: Bearer <session-token>Deploy note
Reaching prod requires: merge → bump
cloud/.objectui-shato this commit → rebuild + deploy the objectos image.🤖 Generated with Claude Code