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

Support pre-filling Trusted Publisher form via URL params #16399

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

facutuesca
Copy link
Contributor

@facutuesca facutuesca commented Aug 5, 2024

What is this?

This PR adds support for pre-filling the Trusted Publisher form via URL parameters. That is, opening the following URL (while logged in):

https://pypi.org/manage/project/my_project/settings/publishing/?provider=github&owner=my_user&repository=my_project&workflow_filename=my_workflow.yml

will open the page to create a new Trusted Publisher for my_project with the fields pre-filled:

image

This fixes #13661 (see the last comment)

Design & implementation considerations

  • This is only implemented for the Project view, since the usecase is generating magic links to create a Trusted Publisher for an existing project. The concrete usecase is for the GH action gh-action-pypi-publish to generate a link and show it to the user whenever it's used to publish using an API token, encouraging the user to create a Trusted Publisher for that (existing) project by clicking on the magic link.
  • The only required parameter to enable pre-filling is provider. Any provider can be specified (github, gitlab, google and activestate) and they are case-insensitive.
  • The name of the parameters (owner, email, etc) are the same as the name of the form fields. This allows us to keep the implementation simple by using the URL parameters to fill the form directly without an intermediary mapping between URL param names and form field names.
  • The URL parameters do not need to have all of the form's fields. Missing fields will just be left empty.
  • URL parameters that do not match any form fields will be ignored.
  • If an unknown provider is specified, nothing is done (all fields will be empty, like the default view).
  • The tab for the pre-filled provider will be selected on page load.
  • A warning will be shown when using this feature, asking the user to double-check the values since they have been pre-filled (see the screenshot above).

cc @woodruffw @webknjaz @di

Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

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

LGTM. This is blocked on pypi/infra#169.

@facutuesca facutuesca force-pushed the trusted-publishing-magic-link branch from 8abc436 to 1c5696c Compare August 13, 2024 08:27
@facutuesca facutuesca force-pushed the trusted-publishing-magic-link branch from 1c5696c to ca32ab2 Compare August 13, 2024 08:38
@di di merged commit a971bd9 into pypi:main Aug 13, 2024
17 checks passed
@di di deleted the trusted-publishing-magic-link branch August 13, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trusted publishing: pre-fill registration fields, when possible
3 participants