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

Document the trusted publisher exchange token API #353

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
repository: rubygems/rubygems
path: rubygems
ref: 3.4
ref: 3.5

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ GEM
google-protobuf (~> 3.23)
sass-embedded (1.69.5-x86_64-linux-gnu)
google-protobuf (~> 3.23)
stringio (3.0.1)
stringio (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tomlrb (2.0.1)
Expand Down
18 changes: 18 additions & 0 deletions rubygems-org-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,24 @@ Retrieve your API key using HTTP basic auth.
"rubygems_api_key": "701243f217cdf23b1370c7b66b65ca97"
}

### POST - `/api/v1/oidc/trusted_publisher/exchange_token`

Exchange an OIDC ID token for a RubyGems API key. This endpoint is intended to be used by the
[`release-gem`](github.com/rubygems/release-gem) GitHub Action for [trusted publishing](/trusted-publishing/releasing-gems).

The request body must be a JSON object with a single key, `jwt`, whose value is the ID token (as a string).

$ curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"jwt": $ID_TOKEN}' \
https://rubygems.org/api/v1/oidc/trusted_publisher/exchange_token"

{
"rubygems_api_key": "rubygems_701243f217cdf23b1370c7b66b65ca97",
"name": "GitHub Actions rubygems/configure-rubygems-credentials @ .github/workflows/token.yml",
"scopes": ["push_rubygem"],
"expires_at": "2021-01-01T00:00:00Z"
}

### GET - `/api/v1/dependencies?gems=[COMMA DELIMITED GEM NAMES]`

Returns a marshalled array of hashes for all versions of given gems. Each hash
Expand Down
2 changes: 1 addition & 1 deletion trusted-publishing/releasing-gems.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
- uses: rubygems/release-gem@v1
```

Note the `id-token: write`` permission: you **must** provide this permission at either the job level (strongly recommended) or workflow level (discouraged). Without it, the publishing action won't have sufficient permissions to identify itself to RubyGems.org.
Note the `id-token: write` permission: you **must** provide this permission at either the job level (strongly recommended) or workflow level (discouraged). Without it, the publishing action won't have sufficient permissions to identify itself to RubyGems.org.
Loading