Skip to content

feat(auth): add workspace API key support#560

Open
yoavf wants to merge 3 commits into
mainfrom
codex/workspace-api-key-auth
Open

feat(auth): add workspace API key support#560
yoavf wants to merge 3 commits into
mainfrom
codex/workspace-api-key-auth

Conversation

@yoavf

@yoavf yoavf commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Note

Description

Adds support for workspace API key authentication (b44k_...) so machine principals (CI, agents, provisioning tools) can deploy without an interactive OAuth login. When BASE44_API_KEY is set to a workspace key, the shared base44Client sends it as the api_key header, OAuth token refresh is skipped, and no auth.json is written. Also fixes a deploy-time issue where connectors were synced even when none were configured, and improves the 401 error hint for rejected workspace keys.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Workspace API key auth: Added getWorkspaceApiKeyFromEnv(), isWorkspaceApiKey(), and hasWorkspaceApiKeyAuth() helpers in core/auth/config.ts (keyed on the b44k_ prefix).
  • Client wiring: base44Client sets the api_key header and skips OAuth readAuth/token refresh when a valid workspace key is present; handleUnauthorized no longer attempts a refresh-retry for key-based auth.
  • Auth middleware: ensureAuth short-circuits for workspace-key auth (no login/seed required) and sets a workspace-api-key principal on the error reporter.
  • whoami: Reports the workspace key prefix instead of a logged-in email when a workspace key is in use.
  • Error hints: A 401 while using a workspace key now surfaces an actionable message about verifying BASE44_API_KEY instead of suggesting base44 login.
  • Deploy fix: deployAll skips pushConnectors entirely when no connectors are configured, avoiding a needless/forbidden connectors-list call.
  • Docs: Documented workspace API keys vs. OAuth access/refresh tokens in docs/api-patterns.md.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The usingWorkspaceApiKey() check in core/errors.ts is intentionally inlined (rather than imported from core/auth/config) to avoid a circular import, since auth/config depends on errors for its error classes. New tests in tests/cli/env-token-auth.spec.ts cover whoami output, the api_key header, the rejected-key hint, and ignoring non-b44k_ values when OAuth auth exists.


🤖 Generated by Claude | 2026-07-07 21:17 UTC | 079a819

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.2-pr.560.079a819

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.2-pr.560.079a819"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.2-pr.560.079a819"
  }
}

Preview published to npm registry — try new features instantly!

Comment thread packages/cli/src/core/clients/base44-client.ts
guyofeck
guyofeck previously approved these changes Jul 7, 2026

@guyofeck guyofeck left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment

A rejected BASE44_API_KEY previously surfaced the generic 401 hint
("Try logging in again → base44 login"), which is useless for a
non-interactive CI principal that has no login flow. Detect the
workspace key and return a targeted hint instead.

The check is inlined in errors.ts rather than imported from
core/auth/config to avoid a circular import (auth/config depends on
this module for its error classes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@guyofeck

guyofeck commented Jul 7, 2026

Copy link
Copy Markdown

@yoavf pushed a small follow-up (70807ee) for the 401 case on workspace keys.

A rejected BASE44_API_KEY was falling through to the generic 401 hint ("Try logging in again → base44 login"), which isn't actionable for a CI principal with no login flow. getDefaultHints now detects the workspace key and returns a targeted hint instead. Added a test in env-token-auth.spec.ts.

The workspace-key check is inlined in errors.ts rather than imported from core/auth/config — importing it created a circular dependency (auth/config already depends on errors for its error classes) that broke class-init order in the bundle. Feel free to fold it into your own follow-up or adjust the wording.

@guyofeck

guyofeck commented Jul 8, 2026

Copy link
Copy Markdown

#skipreview

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by guyofeck was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

1 similar comment
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

10 similar comments
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

1 similar comment
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

1 similar comment
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

1 similar comment
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

1 similar comment
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

2 similar comments
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

2 similar comments
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

9 similar comments
@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes.

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by wix-s-github-tools[bot] was blocked by GitHub (HTTP 403 — likely a rate limit or permission issue). Please retry #skipreview (or /skipreview) in a few minutes.
GitHub error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@wix-s-github-tools

Copy link
Copy Markdown

Skip-review by wix-s-github-tools[bot] could not be approved due to a GitHub API error: repos/base44/cli/pulls/560/reviews failed with 403 ,responseBody: Forbidden
If the issue persists, contact #dx-platform.

@tomasmaci

Copy link
Copy Markdown

skipreview is not installed in this org, it surfaced a bug of this comment loop. @guyofeck fyi

await authConfigResource.push(authConfig);
const { results: connectorResults } = await pushConnectors(connectors);
const connectorResults =
connectors.length > 0 ? (await pushConnectors(connectors)).results : [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: this breaks connector removal.

pushConnectors([]) was not a needless call — it's the reconcile half of deploy. syncOAuthConnectors removes remote connectors that are no longer in local config (connector/push.ts:83-99), and syncStripeConnector(undefined) removes Stripe when it's installed remotely but absent locally (stripe.ts:35). With this change, deleting your last connector from config and deploying leaves it connected remotely forever — silently. (Removing one-of-several still works since the list stays non-empty.)

The deploy.spec.ts change also locks the regression in: mocking the list endpoint as a 403 makes the test fail if the reconcile call ever comes back.

If the motivation is that workspace API keys get a 403 on the connectors-list endpoint, scope the skip to that case (hasWorkspaceApiKeyAuth() && connectors.length === 0) or fix the permission server-side — don't change deploy semantics for OAuth users.

@tomasmaci

Copy link
Copy Markdown

/skipreview

@wix-s-github-tools

Copy link
Copy Markdown

skipreview by tomasmaci is not available in org base44.
If the issue persists, contact #dx-platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants