Skip to content

Commit 7a0c198

Browse files
committed
PEP 807: split rationale/motivation
Signed-off-by: William Woodruff <william@astral.sh>
1 parent d4f3cfc commit 7a0c198

1 file changed

Lines changed: 36 additions & 8 deletions

File tree

peps/pep-0807.rst

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ of Trusted Publishing, while allowing other indices to implement the same
2323
scheme in a manner that is discoverable by and interoperable with existing
2424
Python package uploading clients.
2525

26-
Rationale and Motivation
27-
========================
26+
Motivation
27+
==========
2828

2929
"Trusted Publishing" is PyPI's term of art for using the
3030
`OpenID Connect (OIDC) standard <https://openid.net/connect/>`_
@@ -53,6 +53,33 @@ clients (like `twine <https://twine.readthedocs.io/en/stable/>`_ and
5353
between indices (leading to an accretion of hacks) or continue to reject
5454
non-PyPI implementations of Trusted Publishing.
5555

56+
Rationale
57+
=========
58+
59+
The lack of an existing standard for Trusted Publishing is the primary
60+
rationale for this PEP.
61+
62+
The design proposed in this PEP closely follows PyPI's existing implementation,
63+
with an added layer of `discovery <Trusted Publishing Discovery>`__
64+
that enables uploading clients to determine whether an arbitrary index
65+
supports Trusted Publishing without making PyPI-specific assumptions.
66+
67+
The rationale for this design is as follows:
68+
69+
1. The existing (unstandardized) implementation of Trusted Publishign on PyPI
70+
has a proven track record, and is already widely adopted in uploading tools.
71+
A significant deviation from the existing design would introduce
72+
unnecessary compatibility risks.
73+
2. The discovery mechanism proposed in this PEP is designed to be
74+
consistent with existing standards for machine-to-machine protocols,
75+
namely :rfc:`8615` (Well-Known URIs). Additionally, this discovery mechanism
76+
is designed to allow multiple indices to be hosted under a single
77+
domain, which is a common topology for third-party index hosts.
78+
79+
In sum, the rationale for this PEP is to standardize PyPI's existing
80+
interfaces *and* make them discoverable while allowing index hosts
81+
that don't match PyPI's topology to implement Trusted Publishing.
82+
5683
Specification
5784
=============
5885

@@ -168,15 +195,16 @@ error code in the 400 or 500 range to indicate an error condition.
168195

169196
Non-``200 OK``, non-``404 Not Found`` responses **MAY** include a body which,
170197
if present, **MUST** be a JSON object containing an
171-
`Error Response`_.
198+
`Error Response <Error Responses>`_.
172199

173200
.. _token-exchange:
174201

175202
Trusted Publishing Token Exchange
176203
---------------------------------
177204

178-
Once an uploading client has performed a successful :ref:`discovery <discovery>`
179-
flow, it can proceed to perform the actual Trusted Publishing token exchange.
205+
Once an uploading client has performed a successful
206+
`discovery <Trusted Publishing Discovery>`__ flow, it can proceed to perform
207+
the actual Trusted Publishing token exchange.
180208

181209
Token exchange occurs in three steps:
182210

@@ -199,7 +227,7 @@ Audience Retrieval
199227

200228
To retrieve the expected OIDC audience, the uploading client performs
201229
an HTTP GET request to the *audience endpoint* obtained during
202-
:ref:`discovery <discovery>`.
230+
`discovery <Trusted Publishing Discovery>`__.
203231

204232
On success, the server responds with a ``200 OK`` status code and a body
205233
containing a JSON object with the following field:
@@ -224,7 +252,7 @@ proceed to mint an upload credential.
224252

225253
To mint an upload credential, the uploading client performs
226254
an HTTP POST request to the *mint token endpoint* obtained during
227-
:ref:`discovery <discovery>`.
255+
`discovery <Trusted Publishing Discovery>`__.
228256

229257
On success, the server responds with a ``200 OK`` status code and a body
230258
containing a JSON object with the following fields:
@@ -356,7 +384,7 @@ However, this approach also has downsides:
356384

357385
Another alternative idea considered was the perform "implicit" discovery,
358386
similar to what PyPI currently does for Trusted Publishing: instead of an
359-
explicit :ref:`discovery <discovery>` step, the uploading client could jump
387+
explicit `discovery <Trusted Publishing Discovery>`__ step, the uploading client could jump
360388
straight to attempting the audience and token minting steps, and
361389
handle any errors that arise.
362390

0 commit comments

Comments
 (0)