Skip to content

Commit

Permalink
Add auth flow option to KeyOpts. (#1827)
Browse files Browse the repository at this point in the history
This change adds an option for callers to manually select the fulcio
auth flow to go through. This allows callers that don't fit into the
default heuristic to have some control over how cosign is invoked.

For now, this is only added as a KeyOpt and not a flag, since this is
currently only needed by tools calling the cosign libraries, not cosign
itself. Flags can be added on later if needed.

This change should not have any impact on existing cosign behavior.

Signed-off-by: Billy Lynch <billy@chainguard.dev>
  • Loading branch information
wlynch authored May 2, 2022
1 parent 2d37669 commit 8efb042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/cosign/cli/fulcio/fulcio.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func NewSigner(ctx context.Context, ko options.KeyOpts) (*Signer, error) {

var flow string
switch {
case ko.FulcioAuthFlow != "":
// Caller manually set flow option.
flow = ko.FulcioAuthFlow
case idToken != "":
flow = FlowToken
case !term.IsTerminal(0):
Expand Down
4 changes: 4 additions & 0 deletions cmd/cosign/cli/options/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type KeyOpts struct {
OIDCClientSecret string
OIDCRedirectURL string
BundlePath string
// FulcioAuthFlow is the auth flow to use when authenticating against
// Fulcio. See https://pkg.go.dev/github.com/sigstore/cosign/cmd/cosign/cli/fulcio#pkg-constants
// for valid values.
FulcioAuthFlow string

// Modeled after InsecureSkipVerify in tls.Config, this disables
// verifying the SCT.
Expand Down

0 comments on commit 8efb042

Please sign in to comment.