-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: adds support for oidc publish #8336
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
base: latest
Are you sure you want to change the base?
Conversation
|
@ljharb 👋
I've thought about this a lot. I also want this, but I question its necessity. If you have
Not really possible. The whole point of OIDC is to have a trusted publisher (like GitLab or GitHub) as the issuer of a token that the registry trusts. A local machine isn't a trusted issuer, so we wouldn't be able to validate any token you could provide. |
Right, but what if an attacker configures OIDC on npmjs.com unbeknownst to me? I'd still want to ensure CI can't publish with it. So to clarify, the reason it's not possible is because the npm servers only have a finite hardcoded list of "trusted OIDC publishers", and i'm not on it? |
80c39ba
to
3a930c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So clean, so boilerplate. Let's leave this unmerged for at least a little while to see if any more community input happens.
If an attacker has access to your npmjs.com account, they can just make gat tokens, I think OIDC would be the least of your worries 🤔 . Further expanding on this idea if a malicious actor got access to your account and added a trusted connection to one of THEIR repos, with their own workflow a
Yeah, kinda |
Just to chime in, I'm onboard and supportive w/ the decision to avoid a cli parameter here for the sake of feature streamlining. Security wise, the malicious access goes similarly to creating access tokens, as mentioned above.
By finite we are kick starting this feature w/ 2 trusted publishers: GitHub Actions and GitLab. This is an MVP and we want to understand the usage feedback for the next iterations on this feature. If possible, I'd really love if we can shift other feature requests and feedback at the community discussion post as it makes it easier for me to track feedback received and we keep this PR limited to new changes added to the repo. |
#8399) Co-authored-by: Chris Sidi <hashtagchris@github.com>
🎉 Introducing OIDC Support for npm Publishing!
We're thrilled to announce a new security feature that makes publishing npm packages from CI environments easier and more secure! This PR adds OpenID Connect (OIDC) token support for npm publishing, which eliminates the need to store long-lived access tokens in CI secrets.
With OIDC support, you can now publish packages from GitHub Actions and GitLab CI with improved security through short-lived, automatically generated tokens. This is a major step forward in securing the npm ecosystem and simplifying CI/CD workflows.
Technical Details
This implementation adds OIDC token support by:
The feature is designed to be non-invasive - it only activates in CI environments and gracefully falls back to traditional authentication methods when OIDC isn't available.
For Publishers
Updating Package Settings on npmjs.com
Warning
Not live yet, OIDC support is currently under development. The CLI,
npmjs.com
, and registry changes will be rolled out incrementally. Stay tuned for a public preview announcement. As of now, this documentation reflects features planned for a future release.Important
In order to use OIDC publishing, a package must already exist on npmjs.com. This means the initial publish needs to be done through conventional means; further publishes, once configured, can use OIDC.
Before using OIDC for publishing, ensure your package settings on npmjs.com are configured to allow CI/CD workflows.
This step ensures that your package is ready to accept tokens generated via OIDC workflows.
GitHub Actions
To publish with OIDC from GitHub Actions:
id-token: write
permission to your workflow:NPM_TOKEN
secrets anymore! Just run npm publish as usual:GitLab CI
To publish with OIDC from GitLab CI:
NPM_ID_TOKEN
environment variable:For other CLI's
If you're building a CLI tool that publishes to npm registries, you can implement OIDC support by:
ACTIONS_ID_TOKEN_REQUEST_URL
endpoint with the proper audience format (npm:registry.hostname
)NPM_ID_TOKEN
environment variable if availableFor other Registries
As a registry, you'll need a way for package publishers to create connections between OIDC Trusted Publishers and the registry, similar to how we allow connections to be added on the package settings page of npmjs.com.
To support OIDC token authentication in your npm-compatible registry:
Implement an endpoint at
/-/npm/v1/oidc/token/exchange
that accepts POST requests with:Verify the OIDC token using standard JWT validation practices, checking the audience claim matches your expected format (
npm:your.registry.hostname
)Return a response with a short-lived npm token:
Technical Overview
oidc.js
handles:publish
command →libnpmpublish
module →npm-registry-fetch
Key touchpoints:
This initial implementation is focused on the publish workflow only. Currently OIDC token support is limited to the publish command.