Skip to content

Commit 6fc943c

Browse files
committed
feat:(oidc) derive audience claim from client_id in IdentityToken
Signed-off-by: SequeI <asiek@redhat.com>
1 parent 6ae464b commit 6fc943c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ All versions prior to 0.9.0 are untracked.
1212

1313
* Added support for ed25519 keys.
1414
[#1377](https://github.com/sigstore/sigstore-python/pull/1377)
15+
* Added client_id as the audience (aud) claim when initializing IdentityToken
16+
[#1402](https://github.com/sigstore/sigstore-python/pull/1402)
17+
1518

1619
### Fixed
1720

sigstore/_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ def _add_shared_oidc_options(
238238
help="Force an out-of-band OAuth flow and do not automatically start the default web browser",
239239
)
240240

241-
242241
def _parser() -> argparse.ArgumentParser:
243242
# Arguments in parent_parser can be used for both commands and subcommands
244243
parent_parser = argparse.ArgumentParser(add_help=False)

sigstore/oidc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"https://oauth2.sigstage.dev/auth": "email",
4242
"https://token.actions.githubusercontent.com": "sub",
4343
}
44-
_DEFAULT_AUDIENCE = "sigstore"
4544

45+
_DEFAULT_AUDIENCE = "sigstore"
4646

4747
class _OpenIDConfiguration(BaseModel):
4848
"""
@@ -66,7 +66,7 @@ class IdentityToken:
6666
a sensible subject, issuer, and audience for Sigstore purposes.
6767
"""
6868

69-
def __init__(self, raw_token: str) -> None:
69+
def __init__(self, raw_token: str, client_id: str) -> None:
7070
"""
7171
Create a new `IdentityToken` from the given OIDC token.
7272
"""
@@ -90,7 +90,7 @@ def __init__(self, raw_token: str) -> None:
9090
# See: https://openid.net/specs/openid-connect-basic-1_0.html#IDToken
9191
"require": ["aud", "sub", "iat", "exp", "iss"],
9292
},
93-
audience=_DEFAULT_AUDIENCE,
93+
audience=client_id,
9494
# NOTE: This leeway shouldn't be strictly necessary, but is
9595
# included to preempt any (small) skew between the host
9696
# and the originating IdP.
@@ -350,7 +350,7 @@ def identity_token( # nosec: B107
350350
if token_error is not None:
351351
raise IdentityError(f"Error response from token endpoint: {token_error}")
352352

353-
return IdentityToken(token_json["access_token"])
353+
return IdentityToken(token_json["access_token"], client_id)
354354

355355

356356
class IdentityError(Error):

0 commit comments

Comments
 (0)