Repository navigation
Trusted publishing: GitHub Actions OIDC exchange and composite action - #14
Merged
Merged
Conversation
`flb publish` can publish without a stored secret: in a job with `id-token: write` it requests the GitHub OIDC token (audience: the registry's host name, FLB_OIDC_AUDIENCE overrides), exchanges it with POST /v1/auth/oidc/github for a short-lived flbt_ token scoped to the extension (named by its npm package, else composer), and uses that token for the listing lookup, upload and checks. - Token order for publish: FLB_TOKEN, then the exchange when ACTIONS_ID_TOKEN_REQUEST_URL/TOKEN are set (or --oidc), then the stored login; --no-oidc skips it. Other commands are unchanged. - The exchange runs after the build and again when the token is within two minutes of expiry (RegistryClient gains a tokenProvider), so long check runs outlive the ~15 minute token. - Actionable errors: missing OIDC variables or a refused GitHub request point at `permissions: id-token: write`; 401 names the audience; 403 names the repository, workflow file and ref to configure in Studio → Access. A GitHub Actions job with no token at all gets the same hint. - Trusted publishing never creates a listing or adds a package to one. - flbt_ tokens are service tokens (not legacy) and are redacted in output, as are JWTs. Neither token is printed or written to disk. action/: a composite action (fleetbase/fleetbase-cli/action@v2) that sets up Node, installs @fleetbase/cli (or builds it from the action's checkout with cli-version: source), runs `flb publish --json` and exposes release-id, version, status, channel and extension, with a job summary. action/examples/publish-on-tag.yml publishes on tag push. README documents the setup.
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.
Summary
flb publishcan now publish from GitHub Actions without any stored secret. A job withid-token: writerequests a GitHub OIDC token and trades it for a short-lived, publish-onlyflbt_token for the extension. This repo also gains a composite action,fleetbase/fleetbase-cli/action@v2, that wraps it.CLI
flb publish:FLB_TOKEN, then the OIDC exchange whenACTIONS_ID_TOKEN_REQUEST_URL/_TOKENare set (or--oidc), then the stored login.--no-oidcskips the exchange. No other command changes.${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=<registry host name>with the request token as bearer (FLB_OIDC_AUDIENCEoverrides the audience). It then callsPOST v1/auth/oidc/githubwith{token, extension}, whereextensionis the npm package name, else the composer name.expires_at, because a 15 m check wait can outlast a ~15 min token. To support this,RegistryClientgets atokenProvideroption.permissions: id-token: write.POST v1/publisher/extensions) and never adds a package to one. It fails and says what to do instead.flbt_tokens count as service tokens, not legacy. They are redacted in output, and so are JWTs. Neither token is printed or written to disk.trueinstead of the package kind.Action (
action/)path,registry,channel,submit(default true),wait(default true),timeout,notes,notes-file,token,oidc-audience,install-command,args,cli-version(default^2.0.0-0, orsourceto build the CLI from the action's own checkout),node-version(default 22).release-id,version,status,channel,extension.flb publishfails. The outputs are still set whenever the upload happened.action/examples/publish-on-tag.ymlpublishes on tag push. README.md has a new "Publishing from GitHub Actions" section, andaction/README.mdcovers the action.Notes
@fleetbase/clion npm is still at 0.0.6. The defaultcli-version: ^2.0.0-0only resolves once a v2 build that includes this change is published. Until then, usecli-version: source.npm packplus the composer autoload files. The exception isprepare/prepackscripts; for those, useinstall-commandorargs: --ignore-scripts.POST /v1/auth/oidc/githubplus trusted publishers in Studio → Access, is being built in fleetbase/registry.Tests
npm run typecheck: clean.npm test: 114/114 pass, including the 9 new tests intest/unit/oidc.test.ts.