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

ci: use a trusted publisher token for publishing to PyPI #1061

Merged
merged 9 commits into from
Jan 16, 2024

Conversation

tonyandrewmeyer
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer commented Nov 9, 2023

Remove the use of the PyPI secret in the publish workflow, in favour of using the short-lived OIDC token via the Trusted Publisher system.

PyPI's normal API tokens are long-lived, meaning that an attacker who compromises a package's release token can use it until its legitimate user notices and manually revokes it. Similarly, uploading with a password means that an attacker can upload to any project associated with the account. Trusted publishing avoids both of these problems: the tokens minted expire automatically, and are scoped down to only the packages that they're authorised to upload to.

Also add a (manually triggered) workflow to publish to test.pypi.org to be able to validate that publishing changes (like this one) work as expected, without needing to actually publish.

Fixes #1021

@tonyandrewmeyer tonyandrewmeyer marked this pull request as ready for review November 9, 2023 13:09
Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Looks good. Let's just tweak a couple of names. However, let's wait to merge this till you hear back from test.pypi.org support and have ownership of ops.

.github/workflows/test-publish.yml Outdated Show resolved Hide resolved
.github/workflows/test-publish.yml Outdated Show resolved Hide resolved
tonyandrewmeyer and others added 2 commits November 14, 2023 22:32
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
@tonyandrewmeyer
Copy link
Contributor Author

However, let's wait to merge this till you hear back from test.pypi.org support and have ownership of ops.

👍. This is the support ticket, for reference.

@tonyandrewmeyer
Copy link
Contributor Author

Looks good. Let's just tweak a couple of names. However, let's wait to merge this till you hear back from test.pypi.org support and have ownership of ops.

It looks like the backlog for these requests goes back roughly one year 😞. Some get handled "out of queue" - I did find one that's exactly the same situation and it was one of the "out of queue" ones, so I've adjusted the issue summary to make it clearer that it's only test.pypi.org, but that doesn't seem like it always gets quicker action.

So I think for at least this PR, we should just go ahead with it and can address any issues if they happen.

@benhoyt
Copy link
Collaborator

benhoyt commented Jan 4, 2024

So I think for at least this PR, we should just go ahead with it and can address any issues if they happen.

Yep, sounds right to me, thanks!

@benhoyt benhoyt merged commit 41a4ad4 into canonical:main Jan 16, 2024
26 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the trusted-publisher-1021 branch January 16, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use PyPI's "Trusted Publisher" functionality to publish packages
2 participants