fulcio: add 'device' TokenProvider for OAuth 2.0 device-code flow#825
Open
dustinkirkland wants to merge 1 commit into
Open
fulcio: add 'device' TokenProvider for OAuth 2.0 device-code flow#825dustinkirkland wants to merge 1 commit into
dustinkirkland wants to merge 1 commit into
Conversation
Adds a new value for the GITSIGN_TOKEN_PROVIDER env var / gitsign.tokenProvider config: 'device'. When set, gitsign performs an RFC 8628 device authorization grant directly against cfg.Issuer (default oauth2.sigstore.dev) using the sigstore library's existing oauthflow.NewDeviceFlowTokenGetterForIssuer. The user opens the printed verification URL on any browser (phone, laptop, anywhere) to complete OAuth consent. The SSH session itself never needs a browser, port forward, or localhost callback — useful on remote/headless developer hosts where the interactive flow can't open a local browser. Implementation is parallel to the existing 'interactive' special case: 'device' sets authFlow directly to the DeviceFlowTokenGetter rather than going through the cosign providers registry and the StaticTokenGetter shim. The other registry-backed providers (spiffe, google-impersonation, etc.) are unchanged. Signed-off-by: Dustin Kirkland <dustin.kirkland@chainguard.dev>
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
Adds
deviceas a new value forGITSIGN_TOKEN_PROVIDER/gitsign.tokenProvider. When set, gitsign performs an RFC 8628 device authorization grant directly againstcfg.Issuer(defaulthttps://oauth2.sigstore.dev/auth) using the sigstore library's existingoauthflow.NewDeviceFlowTokenGetterForIssuer.The user opens the printed verification URL on any browser — phone, laptop, second machine, anywhere — to complete OAuth consent. The SSH session itself never needs a browser, port forward, or localhost callback. This unblocks signing on remote / headless developer hosts (long-running SSH sessions, dev VMs with no GUI, etc.) where the existing interactive flow can't open a browser locally and the OOB fallback is clunky.
Implementation
Parallel to the existing
interactivespecial case ininternal/fulcio/identity.go:devicesetsauthFlowdirectly to aDeviceFlowTokenGetterrather than routing through the cosign providers registry and theStaticTokenGettershim. The other registry-backed providers (spiffe,google-impersonation,filesystem, etc.) are unchanged.Three files changed, +17 / -3 lines total:
internal/fulcio/identity.go— the newelse if cfg.TokenProvider == \"device\"branchinternal/config/config.go— comment updated to listdeviceas a valid value with a one-paragraph descriptionREADME.md—tokenProviderconfig row andGITSIGN_TOKEN_PROVIDERenv-var row both updatedHow I validated
Built locally and verified the test suite still passes:
```
$ go build ./...
$ env -u GITSIGN_OIDC_REDIRECT_URL -u GITSIGN_CONNECTOR_ID -u GITSIGN_TOKEN_PROVIDER \
go test ./internal/fulcio/... ./internal/config/...
ok github.com/sigstore/gitsign/internal/fulcio/fulcioroots (cached)
ok github.com/sigstore/gitsign/internal/config 0.003s
```
End-to-end: I'm running a small CLI tool that uses the same
oauthflow.NewDeviceFlowTokenGetterForIssuerAPI to mint an OIDC token and write it to disk, then signing commits via the existing filesystem token provider. With this PR that helper becomes redundant —GITSIGN_TOKEN_PROVIDER=device git commitdoes the whole thing in-process.Related
I have a companion PR at sigstore/cosign#4934 that lets the cosign filesystem provider honor a
SIGSTORE_OIDC_TOKEN_FILEenv var. Bundled framing for both: "headless desktop sigstore signing without sudo". The two PRs are independent and either can land first.A possible follow-up (not in this PR): the underlying
DeviceFlowTokenGetterdoesn't currently forwardconnector_idin the device-code request, so users land on Dex's provider-picker page before being redirected to the chosen IdP. The interactive flow already pre-selects viaExtraAuthURLParams; adding the same to the device flow would be a small sigstore-library PR.🤖 Generated with Claude Code