Repository navigation
fix(api-gateway): require a dev-token scope for the playground bypass [lts/v1.6] - #11579
Merged
Merged
Conversation
Backport of the dev-token gate to the v1.6 LTS line.
`signedWithPlaygroundAuthSecret` unlocks developer affordances — meta
members hidden by `public: false` / access policies, generated SQL,
pre-aggregation and refresh-key debug info, request ids — and was set
purely from the token having verified against `playgroundAuthSecret`.
In Cube Cloud that secret signs every token a deployment mints, including
ones handed to end users and to external BI tools, so the signature alone
was never evidence that the bearer is a developer. Require a `dev-token`
entry in the token's `scope` as well; the control plane adds it only for
the developer-facing console surfaces and only for users with
deployment-manage permissions.
devMode is unaffected: all six consumers of the flag on this branch are
identical to master's, and every behavioural one already ORs with
`getEnv('devMode')`, so a local `cube dev` server keeps full visibility.
Authentication is unchanged — the scope gates what a playground-signed
token may see, not whether it verifies, so `/cubejs-system/v1/*` still
accepts any playground-signed token.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rhtueaPpiVVNkvA5rWv8X
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## lts/v1.6 #11579 +/- ##
=============================================
- Coverage 79.17% 58.75% -20.42%
=============================================
Files 481 224 -257
Lines 97583 17907 -79676
Branches 3652 3655 +3
=============================================
- Hits 77260 10522 -66738
+ Misses 19800 6861 -12939
- Partials 523 524 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
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.
Backport of the
dev-tokengate to the v1.6 LTS line. Runtime half only — the control-plane half that mints the scope lives in cubejs-enterprise and has no counterpart in the LTS image.Upstream: #11571 (merged to master).
Check List
Description of Changes Made
signedWithPlaygroundAuthSecretunlocks the runtime's developer affordances — meta members hidden bypublic: false/ access policies, generated SQL, pre-aggregation and refresh-key debug info, request ids in errors. It was set purely from the token having verified againstplaygroundAuthSecret.In Cube Cloud that secret signs every token a deployment mints, including ones handed to end users and to external BI tools, so the signature alone was never evidence that the bearer is a developer. This requires a
dev-tokenentry in the token'sscopeas well:The grant sits in
scopealongside the runtime's other per-token grants (sql-runner,agents-config) rather than in a claim of its own.What is unaffected
getEnv('devMode'), so a localcube devserver keeps full visibility. The one site reading the flag alone is theisPlaygroundfield on Load Request logs, which correspondingly now marks only developer traffic./cubejs-system/v1/*still accepts any playground-signed token, so service-to-service callers are unchanged.CUBEJS_PLAYGROUND_AUTH_SECRETequal toCUBEJS_API_SECRET, so main auth wins there and the flag was alreadyfalse.Rollout ordering. This is fail-closed, so it must not ship ahead of a control plane that stamps the scope: a runtime deployed first would silently drop hidden-member visibility and generated SQL in the console. The enterprise side is already merged.
Verification
Run locally on this branch, against a from-scratch native build:
npx tsc -p .(v1.6 toolchain, src + tests)npx eslint src/gateway.ts test/auth.test.tsjest dist/test/auth.test.jsThe five added cases pin the strictness that matters: no scope at all, a scope carrying only other grants,
['dev-token']alone and alongsidesql-runner, non-arrayscopeshapes (Array.isArrayguards beforeincludes, so a bare string cannot match by substring), and a main-secret-signed token carrying the scope. Every pre-existing case still passes — includingapiSecrets - playground secret path is unaffectedandapiSecrets - coexists with playgroundAuthSecret, the two most likely to catch a semantic drift on this branch.The
gateway.tsdiff is byte-identical to what merged on master, and both anchor points are structurally the same here, so this is a true backport rather than a re-implementation.🤖 Generated with Claude Code
https://claude.ai/code/session_018rhtueaPpiVVNkvA5rWv8X
Generated by Claude Code