Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sigstore: refactor, use IdentityToken everywhere #635

Merged
merged 27 commits into from
May 24, 2023
Merged

Conversation

woodruffw
Copy link
Member

Key changes:

  • sigstore._internal.oidc.Identity is now stabilized as sigstore.oidc.IdentityToken, and provides attributes similar to the ones originally requested/proposed by @jku in Signing should support issuer and identity arguments too  #567
  • The top level Signer.sign(...) API now takes an IdentityToken rather than a raw str
  • The refactored IdentityToken class now uses the correct IdentityError exception type (the first party one, rather than id.IdentityError
  • The (internal) Fulcio CSR API now takes an IdentityToken rather than a raw str
  • The (internal) CLI helpers now use and return IdentityToken rather raw str objects
  • The (internal) CLI helpers now include _die, which improves our type-checking of the CLI

See #567.

CC @jku

@woodruffw woodruffw added component:signing Core signing functionality refactoring Refactoring tasks. labels Apr 26, 2023
@woodruffw woodruffw requested review from di and tetsuo-cpp April 26, 2023 15:36
@woodruffw woodruffw self-assigned this Apr 26, 2023
Disable old tests temporarily.

Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw marked this pull request as ready for review April 26, 2023 16:25
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw requested a review from tnytown April 26, 2023 16:35
Signed-off-by: William Woodruff <[email protected]>
...still unreachable.

Signed-off-by: William Woodruff <[email protected]>
tnytown
tnytown previously approved these changes Apr 26, 2023
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great from my perspective, apart from one thing: I am interested in the certificate identity issuer which is not necessarily "iss" in the JWT.

So as an example, in this example JWT below the certificate identity details I'm looking for are email and federated_claims.connector_id. I assume in other cases iss is really the certificate issuer.

{
  'iss': 'https://oauth2.sigstore.dev/auth', 
  'sub': '...', 
  'aud': 'sigstore',
  'exp': 1682590933,
  'iat': 1682590873, 
  'nonce': '...', 
  'at_hash': '...',
  'email': '[email protected]',
  'email_verified': True,
  'federated_claims': {
    'connector_id': 'https://github.com/login/oauth',
    'user_id': '...'
  }
}

sigstore/oidc.py Show resolved Hide resolved
@woodruffw woodruffw added this to the 2.0 milestone Apr 27, 2023
tetsuo-cpp
tetsuo-cpp previously approved these changes May 2, 2023
Copy link
Collaborator

@tetsuo-cpp tetsuo-cpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think just the point about federated_connector_id needs to be addressed. But otherwise, the refactor looks great.

@woodruffw woodruffw dismissed stale reviews from tetsuo-cpp and tnytown via efdf103 May 2, 2023 13:55
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
@woodruffw
Copy link
Member Author

I've added IdentityToken.federated_issuer in 45ab029.

@woodruffw
Copy link
Member Author

With regards to naming, it would be good if Fulcio, or Sigstore as a whole system, had an agreed name for this concept so that different clients can use the same name.

Yep, strongly agreed. I wonder if that's something that should go in the client spec, or maybe somewhere else? CC @znewman01

@znewman01
Copy link

Likely the Fulcio spec—CC @haydentherapper

@haydentherapper
Copy link
Contributor

Ack, added a TODO to the spec doc to include this somewhere

@woodruffw woodruffw requested a review from tnytown May 8, 2023 18:20
@woodruffw
Copy link
Member Author

Thanks all! I think this is good to go, pending final review.

@woodruffw woodruffw requested a review from jku May 8, 2023 18:20
tnytown
tnytown previously approved these changes May 8, 2023
Copy link
Collaborator

@tnytown tnytown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New changes LGTM!

sigstore/oidc.py Show resolved Hide resolved
jku
jku previously approved these changes May 9, 2023
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a really good improvement to me, thanks for the patient tweaking.

Left one log content comment and have two other notes but none of these should IMO block this PR:

  • The attribute name does not feel great but your reasoning about it makes sense and I don't have better suggestions. It does feel like identity is a lot like expected_certificate_subject but only one of them has "expected" in the name...
  • IdentityTokens identity and expected_certificate_subject attributes also operate slightly differently: one is pre-computed and the other is not. I don't think this matters much

sigstore/sign.py Outdated Show resolved Hide resolved
@woodruffw
Copy link
Member Author

  • The attribute name does not feel great but your reasoning about it makes sense and I don't have better suggestions. It does feel like identity is a lot like expected_certificate_subject but only one of them has "expected" in the name...

Yeah, fully agreed -- I'm vacillating between expected and effective, but I think both are confusing/non-ideal in ways that the other doesn't address 🙂

Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw dismissed stale reviews from jku and tnytown via d9fcc91 May 9, 2023 15:17
@woodruffw woodruffw requested a review from tetsuo-cpp May 9, 2023 15:30
tetsuo-cpp
tetsuo-cpp previously approved these changes May 10, 2023
Copy link
Collaborator

@tetsuo-cpp tetsuo-cpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newest changes LGTM!

@woodruffw woodruffw enabled auto-merge (squash) May 10, 2023 13:23
Signed-off-by: William Woodruff <[email protected]>
Seemingly not needed?

Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw requested a review from tetsuo-cpp May 23, 2023 20:41
@woodruffw woodruffw merged commit 2593923 into main May 24, 2023
@woodruffw woodruffw deleted the ww/identity-refactor branch May 24, 2023 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:signing Core signing functionality refactoring Refactoring tasks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants