Skip to content

Commit 4e2b59a

Browse files
authored
cli: add a flag for disabling ambient OIDC detection (sigstore#68)
* cli: add a flag for disabling ambient OIDC detection Signed-off-by: William Woodruff <william@trailofbits.com> * README: update `sigstore sign --help` Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent 177e415 commit 4e2b59a

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ Signing:
5555
Usage: sigstore sign [OPTIONS] FILE [FILE ...]
5656
5757
Options:
58-
--identity-token TEXT
58+
--identity-token TEXT the OIDC identity token to use
5959
--ctfe FILENAME
60-
--help Show this message and exit.
60+
--oidc-disable-ambient-providers
61+
Disable ambient OIDC detection (e.g. on
62+
GitHub Actions)
63+
--help Show this message and exit.
6164
```
6265
<!-- @end-sigstore-sign-help@ -->
6366

sigstore/_cli.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,45 @@ def main():
3131

3232

3333
@main.command("sign")
34-
@click.option("identity_token", "--identity-token", type=click.STRING)
34+
@click.option(
35+
"identity_token",
36+
"--identity-token",
37+
type=click.STRING,
38+
help="the OIDC identity token to use",
39+
)
3540
@click.option(
3641
"ctfe_pem",
3742
"--ctfe",
3843
type=click.File("rb"),
3944
default=resources.open_binary("sigstore._store", "ctfe.pub"),
4045
)
46+
@click.option(
47+
"oidc_disable_ambient_providers",
48+
"--oidc-disable-ambient-providers",
49+
is_flag=True,
50+
default=False,
51+
help="Disable ambient OIDC detection (e.g. on GitHub Actions)",
52+
)
4153
@click.argument(
42-
"files", metavar="FILE [FILE ...]", type=click.File("rb"), nargs=-1, required=True
54+
"files",
55+
metavar="FILE [FILE ...]",
56+
type=click.File("rb"),
57+
nargs=-1,
58+
required=True,
4359
)
44-
def _sign(files, identity_token, ctfe_pem):
60+
def _sign(files, identity_token, ctfe_pem, oidc_disable_ambient_providers):
4561
# The order of precedence is as follows:
4662
#
4763
# 1) Explicitly supplied identity token
48-
# 2) Ambient credential detected in the environment
64+
# 2) Ambient credential detected in the environment, unless disabled
4965
# 3) Interactive OAuth flow
50-
if not identity_token:
66+
if not identity_token and not oidc_disable_ambient_providers:
5167
identity_token = detect_credential()
5268
if not identity_token:
5369
identity_token = get_identity_token()
70+
if not identity_token:
71+
click.echo("No identity token supplied or detected!", err=True)
72+
raise click.Abort
5473

5574
ctfe_pem = ctfe_pem.read()
5675
for file in files:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy