Repository navigation
Report the OIDC identity npm presents to the registry #543
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| """Exercise release orchestration without any real remote writes or publication.""" | ||
| from __future__ import annotations | ||
|
|
||
| import base64 | ||
| import hashlib | ||
| import json | ||
| import os | ||
|
|
@@ -231,6 +232,31 @@ def test_publication_reruns_skip_npm_and_update_github(self) -> None: | |
| self.assertIn(str(Path('dist') / 'fixture.unitypackage.sha256'), commands[-1]) | ||
| self.assertIn('--clobber' if exists else '--verify-tag', commands[-1]) | ||
|
|
||
| def test_registry_identity_reports_the_claims_npm_presents(self) -> None: | ||
| claims = {'repository': 'owner/repository', 'repository_owner': 'owner', 'workflow': 'Release', 'environment': ''} | ||
| payload = base64.urlsafe_b64encode(json.dumps(claims).encode('utf-8')).decode('ascii').rstrip('=') | ||
| token = f'header.{payload}.signature' | ||
| self.assertEqual(workflow.jwt_claims(token), claims) | ||
| self.assertEqual(workflow.jwt_claims('opaque'), {}) | ||
| self.assertEqual(self.driver.oidc_identity(), '') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove OIDC credentials for the missing-context test.
|
||
|
|
||
| class Response: | ||
| def read(self) -> bytes: | ||
| return json.dumps({'value': token}).encode('utf-8') | ||
|
|
||
| def __enter__(self) -> 'Response': | ||
| return self | ||
|
|
||
| def __exit__(self, *arguments: object) -> bool: | ||
| return False | ||
|
|
||
| self.driver.environment.update(ACTIONS_ID_TOKEN_REQUEST_URL='https://oidc.invalid/request', ACTIONS_ID_TOKEN_REQUEST_TOKEN='token') | ||
| with patch.object(workflow.urllib.request, 'urlopen', return_value=Response()): | ||
| report = self.driver.oidc_identity() | ||
| self.assertIn("repository='owner/repository'", report) | ||
| self.assertIn("workflow='Release'", report) | ||
| self.assertNotIn('signature', report) | ||
|
|
||
| def test_npm_debug_log_supplies_the_registry_reason(self) -> None: | ||
| logs = self.root / 'npm-logs' | ||
| logs.mkdir() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe the claims as a diagnostic token identity.
publish_npm()callsoidc_identity()after every publish failure. If npm fails before an OIDC exchange, this method still requests a new token and says npm received its identity. Say that the runner would present these claims, or use wording that asserts an exchange only when the npm output confirms one. (docs.github.com)