{"id":633244,"date":"2023-04-21T09:55:49","date_gmt":"2023-04-21T14:55:49","guid":{"rendered":"https:\/\/news.sellorbuyhomefast.com\/index.php\/2023\/04\/21\/pypi-introduces-trusted-publishers\/"},"modified":"2023-04-21T09:55:49","modified_gmt":"2023-04-21T14:55:49","slug":"pypi-introduces-trusted-publishers","status":"publish","type":"post","link":"https:\/\/newsycanuse.com\/index.php\/2023\/04\/21\/pypi-introduces-trusted-publishers\/","title":{"rendered":"PyPI Introduces \u201cTrusted Publishers\u201d"},"content":{"rendered":"<div data-md-component=\"container\">\n<p>      <main data-md-component=\"main\"><\/p>\n<div data-md-component=\"content\">\n<p>  by: <b>Dustin Ingram \u00b7 <\/b><\/p>\n<p>  <span>2023-04-20<\/span><\/p>\n<p>Starting today, PyPI package maintainers can adopt a new, more secure<br \/>\npublishing method that does not require long-lived passwords or API tokens to<br \/>\nbe shared with external systems.<\/p>\n<h3 id=\"about-trusted-publishing\">About trusted publishing<\/h3>\n<p>&#8220;Trusted publishing&#8221; is our term for using the <a href=\"https:\/\/openid.net\/connect\/\">OpenID Connect (OIDC)<\/a> standard<br \/>\nto exchange short-lived identity tokens between a trusted third-party service<br \/>\nand PyPI. This method can be used in automated environments and eliminates the<br \/>\nneed to use username\/password combinations or manually generated API tokens to<br \/>\nauthenticate with PyPI when publishing.<\/p>\n<p>Instead, PyPI maintainers can configure PyPI to trust an identity provided by a<br \/>\ngiven OpenID Connect Identity Provider (IdP). This allows allows PyPI to verify<br \/>\nand delegate trust to that identity, which is then authorized to request<br \/>\nshort-lived, tightly-scoped API tokens from PyPI. These API tokens never need<br \/>\nto be stored or shared, rotate automatically by expiring quickly, and provide a<br \/>\nverifiable link between a published package and its source.<\/p>\n<h3 id=\"using-trusted-publishing-with-github-actions\">Using trusted publishing with GitHub Actions<\/h3>\n<p>PyPI currently supports trusted publishing with GitHub Actions, using <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/security-hardening-your-deployments\/about-security-hardening-with-openid-connect\">their<br \/>\nsupport for OpenID Connect<\/a>.<\/p>\n<p>After configuring PyPI to trust a given GitHub repository and workflow, users<br \/>\nof the PyPA&#8217;s <a href=\"https:\/\/github.com\/marketplace\/actions\/pypi-publish\">&#8216;pypi-publish&#8217; GitHub Action<\/a> can adopt trusted publishing by<br \/>\nremoving the <code>username<\/code> and <code>password<\/code> fields from their workflow<br \/>\nconfiguration, and adding permissions to generate an identity token:<\/p>\n<div>\n<pre><span><\/span><code><span>jobs:<\/span>\n<span> <\/span>  pypi-publish:\n<span> <\/span>    name: upload release to PyPI\n<span> <\/span>    runs-on: ubuntu-latest\n<span>+    permissions:<\/span>\n<span>+      # IMPORTANT: this permission is mandatory for trusted publishing<\/span>\n<span>+      id-token: write<\/span>\n<span> <\/span>    steps:\n<span> <\/span>      # retrieve your distributions here\n\n<span> <\/span>      - name: Publish package distributions to PyPI\n<span> <\/span>        uses: pypa\/gh-action-pypi-publish@release\/v1\n<span>-        with:<\/span>\n<span>-          username: __token__<\/span>\n<span>-          password: ${{ secrets.PYPI_TOKEN }}<\/span>\n<\/code><\/pre>\n<\/div>\n<p>Using the PyPA&#8217;s GitHub action is strongly recommended, but not required. More<br \/>\ndetails on how to manually exchange tokens are available <a href=\"https:\/\/docs.pypi.org\/trusted-publishers\/using-a-publisher\/#the-manual-way\">in our<br \/>\ndocumentation<\/a>.<\/p>\n<h3 id=\"additional-security-hardening-is-available\">Additional security hardening is available<\/h3>\n<p>PyPI package maintainers can further increase the security of their release<br \/>\nworkflows by configuring trusted publishers to only release from a specific<br \/>\n<a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/targeting-different-environments\/using-environments-for-deployment\">GitHub Actions environment<\/a>.<\/p>\n<p>Configuring an environment is optional, but strongly recommended: with a GitHub<br \/>\nenvironment, you can apply additional restrictions to your trusted GitHub<br \/>\nActions workflow, such as requiring manual approval on each run by a trusted<br \/>\nsubset of repository maintainers.<\/p>\n<h3 id=\"unblocking-future-security-improvements\">Unblocking future security improvements<\/h3>\n<p>In addition to making publishing more secure now, the availability of trusted<br \/>\npublishers unblocks additional future security improvements for PyPI.<\/p>\n<p>Configuring and using a trusted publisher provides a &#8216;strong link&#8217; between a<br \/>\nproject and its source repository, which can allow PyPI to verify related<br \/>\nmetadata, like the URL of a source repository for a project<sup id=\"fnref:1\"><a href=\"http:\/\/blog.pypi.org\/#fn:1\">1<\/a><\/sup>. Additionally,<br \/>\npublishing with a trusted publisher allows PyPI to correlate more information<br \/>\nabout where a given file was published from in a verifiable way.<\/p>\n<p>Finally, although trusted publishers is currently limited to GitHub Actions,<br \/>\nmuch of the underlying work that went into making this feature possible is<br \/>\ngeneralizable and not specific to a single publisher. We&#8217;re interested in<br \/>\nsupporting the ability to publish from additional services that provide OpenID<br \/>\nConnect identities.<\/p>\n<h3 id=\"get-started-today\">Get started today<\/h3>\n<p>To get started with using trusted publishers on PyPI, see our documentation<br \/>\nhere: <a href=\"https:\/\/docs.pypi.org\/trusted-publishers\/\">https:\/\/docs.pypi.org\/trusted-publishers\/<\/a>.<\/p>\n<h3 id=\"acknowledgements\">Acknowledgements<\/h3>\n<p>Funding for this work was provided by the Google Open Source Security Team, and<br \/>\nmuch of the development work was performed by <a href=\"https:\/\/www.trailofbits.com\/\">Trail of Bits<\/a>, with special<br \/>\nthanks to contributor <a href=\"https:\/\/github.com\/woodruffw\">William Woodruff<\/a>.<\/p>\n<p>Many thanks as well to <a href=\"https:\/\/github.com\/webknjaz\">Sviatoslav Sydorenko<\/a>, maintainer of the PyPA&#8217;s<br \/>\n<a href=\"https:\/\/github.com\/marketplace\/actions\/pypi-publish\">&#8216;pypi-publish&#8217; GitHub Action<\/a> for his quick and timely work to add support for<br \/>\ntrusted publishers in the action.<\/p>\n<p>Finally, we want to thank all our beta testers, including GitHub staff, for<br \/>\nworking with us to ensure this feature is intuitive and useful, and for<br \/>\nproviding valuable feedback to improve this feature along the way.<\/p>\n<hr>\n<p><em>Dustin Ingram is a maintainer of the Python Package Index and a director of<br \/>\nthe Python Software Foundation.<\/em><\/p>\n<\/p><\/div>\n<p>      <\/main><\/p><\/div>\n<p><a href=\"https:\/\/blog.pypi.org\/posts\/2023-04-20-introducing-trusted-publishers\/\" class=\"button purchase\" rel=\"nofollow noopener\" target=\"_blank\">Read More<\/a><br \/>\n Blythe Drews<\/p>\n","protected":false},"excerpt":{"rendered":"<p>by: Dustin Ingram \u00b7 2023-04-20 Starting today, PyPI package maintainers can adopt a new, more secure publishing method that does not require long-lived passwords or API tokens to be shared with external systems. About trusted publishing &#8220;Trusted publishing&#8221; is our term for using the OpenID Connect (OIDC) standard to exchange short-lived identity tokens between a<\/p>\n","protected":false},"author":1,"featured_media":633245,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1536,46,42399],"tags":[],"class_list":{"0":"post-633244","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-introduces","8":"category-technology","9":"category-trusted"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/633244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/comments?post=633244"}],"version-history":[{"count":0,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/633244\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media\/633245"}],"wp:attachment":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media?parent=633244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/categories?post=633244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/tags?post=633244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}