Create a trusted-publish credential provider plugin #15761
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
This PR implements a trusted-publish credential provider plugin to solve the security issue described in #15743.
Problem
Currently, when using
cargo publish
with trusted publishing, the temporary API token generated bycrates-io-auth-action
lives unnecessarily longer than needed. The token exists during the entirecargo publish
process, including package verification and compilation, creating an extended attack window.Solution
This PR introduces
cargo-credential-trusted-publish
, a Cargo credential provider that:logout
actionid-token: write
permissionsKey Features
Security Benefits
How to test and review this PR?
Code Review Focus Areas
Core Implementation (
credential/cargo-credential-trusted-publish/src/lib.rs
)Security Features
ACTIONS_ID_TOKEN
requirement)Integration (
credential/cargo-credential-trusted-publish/src/main.rs
)Testing Instructions
1. Unit Tests
cargo test -p cargo-credential-trusted-publish
Expected: 5 tests pass, 1 ignored (requires real OIDC token)
2. Protocol Testing
Expected: All protocol interactions work correctly:
{"v":[1]}
{"Err":{"kind":"url-not-supported"}}
{"Ok":{"kind":"logout"}}
3. Manual Protocol Testing
4. GitHub Actions Integration Testing
Use the provided workflow (
.github/workflows/trusted-publish-example.yml
):dry_run: true
firstReview Checklist
Expected Behavior
In GitHub Actions with OIDC:
Outside GitHub Actions:
References