|
|
Subscribe / Log in / New account

"Trusted publishers" on the Python Package Index

The Python Package Index (PyPI) has, like many language-specific repositories, had ongoing problems with malicious uploads. PyPI is now launching an authentication mechanism called trusted publishers in an attempt to fight this problem.

Instead, PyPI maintainers can configure PyPI to trust an identity provided by a given OpenID Connect Identity Provider (IdP). This allows allows PyPI to verify and delegate trust to that identity, which is then authorized to request short-lived, tightly-scoped API tokens from PyPI. These API tokens never need to be stored or shared, rotate automatically by expiring quickly, and provide a verifiable link between a published package and its source.


to post comments

"Trusted publishers" on the Python Package Index

Posted Apr 22, 2023 20:40 UTC (Sat) by stefanha (subscriber, #55072) [Link] (3 responses)

Can someone explain the practical advantages compared to storing a token in GitHub secrets?

I guess it prevents an exposed token from being used outside of the CI system?

"Trusted publishers" on the Python Package Index

Posted Apr 23, 2023 12:21 UTC (Sun) by jtaylor (subscriber, #91739) [Link] (2 responses)

Generally you could still use these tokens outside of the CI system but compared to long lived stored api tokens, the openid connect token is very short lived. So if you accidentally leak it in for example a job log its not as big a problem as it usually will be expired by the time anyone would see it.

As there are no shared secrets you also don't need to change any stored tokens when for example a project member leaves.

"Trusted publishers" on the Python Package Index

Posted Apr 28, 2023 6:13 UTC (Fri) by LtWorf (subscriber, #124958) [Link] (1 responses)

But per their example you still need to use github secrets to store the credentials to login and obtain a short lived token…

"Trusted publishers" on the Python Package Index

Posted Apr 28, 2023 15:51 UTC (Fri) by jtaylor (subscriber, #91739) [Link]

I don't see that in the example?
Are you referring to https://github.com/marketplace/actions/pypi-publish#advan...
That section is indeed confusing but I assume it just states the action also supports password authentication if you can't use id tokens for your test pypi setup.

github itself will create the token and provide it to your action/job when it is run. The action then passes it on to PyPI which will verify that the token has been signed by a trusted source (with the public keys most likely from https://token.actions.githubusercontent.com/.well-known/o...) and that the signed token metadata matches what you configured in your PyPI project (github project, release environment etc.)


Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds