feat: add npm OIDC trusted publishing support #562
Closed
+881
−29
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.
Add npm OIDC Trusted Publishing Support
Overview
This PR adds support for npm's OIDC trusted publishing, eliminating the need for long-lived
NPM_TOKENsecrets. This provides enhanced security through cryptographic provenance attestation and short-lived credentials.Benefits
NPM_TOKENsecretsChanges
New Input Parameter
oidcAuthboolean input (default:false) to enable OIDC authenticationOIDC Validation
id-token: writepermission is granted in workflowNPM_TOKENconfigurationAuthentication Setup
.npmrccreation in OIDC mode (npm CLI auto-detects OIDC credentials)NPM_TOKENauthenticationEnvironment Variables Handling
ACTIONS_ID_TOKEN_REQUEST_URLandACTIONS_ID_TOKEN_REQUEST_TOKENare passed through to child processesTesting
.github/workflows/test-oidc-validation.yml)Documentation
Backward Compatibility
✅ Fully backward compatible - existing workflows using
NPM_TOKENcontinue to work without any changes.The
oidcAuthparameter defaults tofalse, so this is an opt-in feature.Example Usage
With OIDC (Recommended for New Projects)
Migration Path
For existing projects using
NPM_TOKEN:id-token: writepermissionoidcAuth: trueNPM_TOKENfrom workflow and GitHub secretsPrerequisites for OIDC
id-token: writepermissionAdditional Context
This implementation has been thoroughly tested in production:
Related Issues
Resolves #515 (if exists - npm OIDC support request)