Skip to content

Commit 3f81484

Browse files
woodruffwwebknjaz
andauthored
Apply suggestions from code review
Co-authored-by: Sviatoslav Sydorenko <[email protected]>
1 parent 3bcc409 commit 3f81484

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ PyPI, which is recommended to restrict the access the action has.
6161
The secret used in `${{ secrets.PYPI_API_TOKEN }}` needs to be created on the
6262
settings page of your project on GitHub. See [Creating & using secrets].
6363

64+
6465
### Publishing with OpenID Connect
6566

66-
**IMPORTANT**: This functionality is in beta, and will not work for you
67-
unless you're a member of the PyPI OIDC beta testers' group. For more
68-
information, see [warehouse#12965].
67+
> **IMPORTANT**: This functionality is in beta, and will not work for you
68+
> unless you're a member of the PyPI OIDC beta testers' group. For more
69+
> information, see [warehouse#12965].
6970

7071
This action supports PyPI's [OpenID Connect publishing]
7172
implementation, which allows authentication to PyPI without a manually
@@ -99,6 +100,13 @@ Other indices that support OIDC publishing can also be used, like TestPyPI:
99100
repository-url: https://test.pypi.org/legacy/
100101
```
101102

103+
> **Pro tip**: only set the `id-token: write` permission in the job that does
104+
> publishing, not globally. Also, try to separate building from publishing
105+
> — this makes sure that any scripts maliciously injected into the build
106+
> or test environment won't be able to elevate privileges while flying under
107+
> the radar.
108+
109+
102110
## Non-goals
103111

104112
This GitHub Action [has nothing to do with _building package

oidc-exchange.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
1717
This generally indicates a workflow configuration error, such as insufficient
1818
permissions. Make sure that your workflow has `id-token: write` configured
19-
at either the workflow or job level, e.g.:
19+
at the job level, e.g.:
2020
2121
```yaml
2222
permissions:
2323
id-token: write
2424
```
25+
26+
Learn more at https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings.
2527
"""
2628

2729
# Rendered if the package index refuses the given OIDC token.
@@ -97,7 +99,7 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
9799
)
98100

99101

100-
repository_url = get_normalized_input("repository-url") or "https://pypi.org/legacy/"
102+
repository_url = get_normalized_input("repository-url")
101103
repository_domain = urlparse(repository_url).netloc
102104
token_exchange_url = f"https://{repository_domain}/_/oidc/github/mint-token"
103105

0 commit comments

Comments
 (0)