Skip to content

Commit d4f3cfc

Browse files
woodruffwAA-Turner
andauthored
Apply suggestions from code review
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 2a86924 commit d4f3cfc

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

peps/pep-0807.rst

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Status: Draft
77
Type: Standards Track
88
Topic: Packaging
99
Created: 15-Sep-2025
10-
Post-History: `08-Aug-2025 <https://discuss.python.org/t/pre-pep-trusted-publishing-token-exchange/103067>`__
10+
Post-History: `08-Aug-2025 <https://discuss.python.org/t/103067>`__,
1111

1212
Abstract
1313
========
@@ -35,7 +35,7 @@ to the index.
3535

3636
Trusted Publishing was originally designed and enabled on PyPI in 2023 as
3737
a non-standard (PyPI-specific) feature, much like the existing
38-
`upload API <https://docs.pypi.org/trusted-publishers/>`_. It has seen
38+
`upload API <https://docs.pypi.org/api/upload/>`__. It has seen
3939
widespread adoption in that capacity: over 640,000 files have been published
4040
to PyPI using a Trusted Publisher (as of September 2025), and PyPI's
4141
design has inspired similar designs in the
@@ -63,16 +63,15 @@ This PEP's specification contains two parts:
6363
* A *token exchange* mechanism that package upload clients can use to
6464
exchange an identity credential for an upload credential.
6565

66-
.. _constraints:
6766

6867
Constraints
6968
-----------
7069

7170
Unless explicitly stated otherwise, the following constraints
7271
apply to all parts of this PEP's specification:
7372

74-
* All URLs **MUST** have
75-
`potentially trustworthy origins <https://www.w3.org/TR/secure-contexts/#potentially-trustworthy-origins>`_.
73+
* All URLs **MUST** have `potentially trustworthy origins
74+
<https://www.w3.org/TR/secure-contexts/#potentially-trustworthy-origins>`__.
7675
In practice, this means that all URLs **MUST** use the ``https``
7776
scheme, be some variant of a local loopback (``localhost``,
7877
``127.0.0.1``, etc.), or otherwise be considered *a priori* trustworthy
@@ -96,13 +95,12 @@ apply to all parts of this PEP's specification:
9695
Receiving servers **SHOULD** respond with a ``406 Not Acceptable``
9796
status code if any other ``Accept`` header is present.
9897

99-
.. _discovery:
10098

10199
Trusted Publishing Discovery
102100
----------------------------
103101

104102
All Python package uploading is currently "endpoint driven," in the sense
105-
uploading clients (like twine and uv) are given an upload URL (and
103+
uploading clients (like *twine* and *uv*) are given an upload URL (and
106104
**not** merely a domain name).
107105

108106
For example, to upload to PyPI, uploading clients are expected to connect
@@ -154,10 +152,10 @@ The discovery mechanism is as follows:
154152

155153
.. code-block:: json
156154
157-
{
158-
"audience-endpoint": "https://upload.example.com/_/oidc/audience",
159-
"token-mint-endpoint": "https://upload.example.com/_/oidc/mint-token"
160-
}
155+
{
156+
"audience-endpoint": "https://upload.example.com/_/oidc/audience",
157+
"token-mint-endpoint": "https://upload.example.com/_/oidc/mint-token"
158+
}
161159
162160
If the server does not support Trusted Publishing for the given
163161
upload URL, it **MUST** respond with a ``404 Not Found`` status code.
@@ -170,7 +168,7 @@ error code in the 400 or 500 range to indicate an error condition.
170168

171169
Non-``200 OK``, non-``404 Not Found`` responses **MAY** include a body which,
172170
if present, **MUST** be a JSON object containing an
173-
:ref:`Error Response <error-responses>`.
171+
`Error Response`_.
174172

175173
.. _token-exchange:
176174

@@ -229,7 +227,7 @@ an HTTP POST request to the *mint token endpoint* obtained during
229227
:ref:`discovery <discovery>`.
230228

231229
On success, the server responds with a ``200 OK`` status code and a body
232-
containing a JSON object with the following field:
230+
containing a JSON object with the following fields:
233231

234232
- ``token``: a string containing the upload credential. The format
235233
of the upload credential is implementation-defined and index-specific.
@@ -314,8 +312,10 @@ has been accompanied by a variety of educational resources on
314312
adopting Trusted Publishing as an end user, including:
315313

316314
* Python Packaging User Guide: :ref:`packaging:trusted-publishing`
317-
* PyPI: `Publishing to PyPI with a Trusted Publisher <https://docs.pypi.org/trusted-publishers/>`_
318-
* pyOpenSci: `Setup Trusted Publishing for secure and automated publishing via GitHub Actions <https://www.pyopensci.org/python-package-guide/tutorials/trusted-publishing.html>`_
315+
* PyPI: `Publishing to PyPI with a Trusted Publisher
316+
<https://docs.pypi.org/trusted-publishers/>`__
317+
* pyOpenSci: `Setup Trusted Publishing for secure and automated publishing via GitHub Actions
318+
<https://www.pyopensci.org/python-package-guide/tutorials/trusted-publishing.html>`__
319319

320320
Rejected Ideas
321321
==============
@@ -325,8 +325,8 @@ Rejected Ideas
325325

326326
This PEP's discovery mechanism uses the ``.well-known`` location scheme
327327
defined in :rfc:`8615`. This scheme is widely adopted by machine-to-machine
328-
protocols, including OpenID Connect itself
329-
(for `OpenID Connect Discovery <https://openid.net/specs/openid-connect-discovery-1_0.html>`_).
328+
protocols, including OpenID Connect itself (for `OpenID Connect Discovery
329+
<https://openid.net/specs/openid-connect-discovery-1_0.html>`__).
330330

331331
An alternative idea considered was to use a "lateral" discovery mechanism,
332332
in which the uploading client would attempt discovery by constructing a
@@ -377,7 +377,9 @@ This approach too has downsides:
377377
the audience and mint token endpoints, which means significant disruption
378378
to existing clients if those endpoints ever need to change.
379379

380-
.. rubric:: Footnotes
380+
381+
Footnotes
382+
=========
381383

382384
.. [#fn-hash] ``shasum -a 256 <<< '/legacy/'``
383385

0 commit comments

Comments
 (0)