Repository navigation
Multi-tenancy: per-team tokens, and releases for this fork - #1
Merged
Merged
Conversation
With one shared TURBO_TOKEN, any team that can use the cache can read and overwrite every other team's artifacts by changing TURBO_TEAM. TURBO_TOKENS_DIR binds each token to one team: the directory holds one file per team, named after the team, containing the SHA-256 hex of that team's token. - A request must name its team (slug, else teamId, the same extraction storage uses) and carry that team's token. No header or an unknown token is 401; a token of another team, or no team named, is 403. - The directory is re-read every 10 seconds, so teams can be added, removed or rotated without a restart; dotfiles (Kubernetes' ..data links) are ignored. An unreadable directory at start stops the server; later, the last good set is kept. - Setting both TURBO_TOKEN and TURBO_TOKENS_DIR stops the server. - With TURBO_TOKENS_DIR unset, behaviour is unchanged. The health check stays open.
The release image is scratch plus one static binary, so an SBOM of it listed no crates. cargo-auditable records the binary's dependency tree in a section of the binary, which Syft and Trivy read: the SBOM now lists the crates the server runs with, and no dev-dependencies.
The README now presents the fork: one cache shared by many teams, each with a token bound to its namespace. It covers the problem a shared token leaves open, the model, tokens and hashes, Kubernetes, adding, removing and rotating tenants without a restart, cleanup, migration from a shared TURBO_TOKEN and security notes. The shared-token and open modes follow as also supported, unchanged. Upstream is credited, and images and the Action point at this repository.
- release.yml, run by hand from main with a version: tags v<version> on a release commit carrying the Action's binaries, pushes the multi-arch image as <version>, <major>.<minor> and latest with BuildKit provenance, a build provenance attestation and a CycloneDX SBOM per platform attached as an OCI referrer (Syft and ORAS pinned and checksum-checked), and creates the GitHub release from CHANGELOG.md. - snapshot.yml, by hand: an amd64 test image sha-<commit> with its SBOM. - ci.yml on pull requests only; build.yml only when packaging changes; warm-build-cache.yml removed. The build cache lives in this repository's package. - CHANGELOG.md (5.1.0, based on upstream 5.0.4), SECURITY.md and a pull request template.
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.
What
Turns the fork into a multi-tenant Turborepo remote cache with its own releases.
feat(auth)).TURBO_TOKENS_DIRis a directory with one file per team: the file name is the team (TURBO_TEAM), the content is the lowercase hex SHA-256 of that team's token./v8/artifactsrequest must carry the token of the team it names. The team comes fromslug, elseteamId, through the same function (team_from_query) that builds the storage key.401. Another team's token:403 {"error":"TURBO_TOKEN is not for this team"}. No team named:403, because this mode has no default namespace...data) are skipped, and so are malformed files (with a warning).TURBO_TOKENandTURBO_TOKENS_DIRtogether: the server refuses to start./management/healthstays open.TURBO_TOKENS_DIRunset, behaviour is unchanged.Dockerfile, so an SBOM of the scratch image lists the crates in the binary. A local check with Syft found 282 components, runtime crates only (no wiremock).release.ymlruns by hand from main with a version. It commits the Action's binaries on a release commit taggedv<version>and pushes the multi-arch imageghcr.io/13axis/turbo-cache-server:<version>,:<major>.<minor>,:latest. The image gets BuildKit provenance, a GitHub build provenance attestation, and a CycloneDX SBOM per platform attached as an OCI referrer (Syft 1.54.1 and ORAS 1.3.4, checksum-checked). It then creates the GitHub release (binaries, SHA256SUMS, SBOMs, attestations) from CHANGELOG.md.snapshot.yml, run by hand, builds an amd64sha-<commit>test image with its SBOM.ci.ymlnow runs on PRs only.build.ymlruns only when packaging changes.warm-build-cache.ymlis removed. The build cache lives in this repo's package.Proposed first release: v5.1.0, based on upstream 5.0.4.
Why
With one shared token, any project can read or poison another project's cache by changing
TURBO_TEAM. Per-team tokens bind each token to its namespace.Checks
cargo fmt --all -- --check: cleancargo clippy --locked --all-targets -- -D warnings: cleancargo test --all-features --locked: 60 unit and 46 HTTP tests pass. New tests: 14 unit tests for team tokens (including a Kubernetes-style symlink swap), 2 for team extraction, and 16 HTTP tests intests/e2e/team_tokens.rs.build.ymlruns on this PR and exercises the Dockerfile change.