feat(auth): add workspace API key support#560
Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.2-pr.560.079a819Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.2-pr.560.079a819"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.2-pr.560.079a819"
}
}
Preview published to npm registry — try new features instantly! |
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>
|
@yoavf pushed a small follow-up (70807ee) for the 401 case on workspace keys. A rejected The workspace-key check is inlined in |
|
#skipreview |
|
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. |
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
1 similar comment
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
10 similar comments
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
1 similar comment
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
1 similar comment
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
1 similar comment
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
1 similar comment
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
2 similar comments
|
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. |
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
2 similar comments
|
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. |
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
9 similar comments
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
|
skipreview by wix-s-github-tools[bot] is temporarily rate-limited. Please retry #skipreview (or /skipreview) in a few minutes. |
|
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. |
|
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 |
|
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 : []; |
There was a problem hiding this comment.
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.
|
/skipreview |
|
skipreview by tomasmaci is not available in org base44. |
Note
Description
Adds support for workspace API key authentication (
b44k_...) so machine principals (CI, agents, provisioning tools) can deploy without an interactive OAuth login. WhenBASE44_API_KEYis set to a workspace key, the sharedbase44Clientsends it as theapi_keyheader, OAuth token refresh is skipped, and noauth.jsonis 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
Changes Made
getWorkspaceApiKeyFromEnv(),isWorkspaceApiKey(), andhasWorkspaceApiKeyAuth()helpers incore/auth/config.ts(keyed on theb44k_prefix).base44Clientsets theapi_keyheader and skips OAuthreadAuth/token refresh when a valid workspace key is present;handleUnauthorizedno longer attempts a refresh-retry for key-based auth.ensureAuthshort-circuits for workspace-key auth (no login/seed required) and sets aworkspace-api-keyprincipal on the error reporter.BASE44_API_KEYinstead of suggestingbase44 login.deployAllskipspushConnectorsentirely when no connectors are configured, avoiding a needless/forbidden connectors-list call.docs/api-patterns.md.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
The
usingWorkspaceApiKey()check incore/errors.tsis intentionally inlined (rather than imported fromcore/auth/config) to avoid a circular import, sinceauth/configdepends onerrorsfor its error classes. New tests intests/cli/env-token-auth.spec.tscover whoami output, theapi_keyheader, the rejected-key hint, and ignoring non-b44k_values when OAuth auth exists.🤖 Generated by Claude | 2026-07-07 21:17 UTC | 079a819