Skip to content

feat(dist-tag): support OIDC authentication - #10038

Open
reggi wants to merge 1 commit into
latestfrom
feat/dist-tag-oidc
Open

reggi wants to merge 1 commit into
latestfrom
feat/dist-tag-oidc

Conversation

@reggi

@reggi reggi commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add OIDC authentication to dist-tag add, remove, and list operations, including scoped registries and workspace listing.
  • Keep exchanged tokens in the non-persistable CLI config layer and clear the previous token before each subsequent OIDC attempt, preventing failed exchanges from reusing another package's token.
  • Keep automatic provenance configuration specific to publishing, and invalidate cached flat options when deleting configuration values.
  • Add coverage for provider exchanges, fallback credentials, workspace token isolation, provenance exclusion, and config cache invalidation.

Notable bug fix: workspace OIDC token reuse

During a single npm publish --workspaces invocation, a successful OIDC exchange for workspace A could leave its package-specific token in shared configuration. If workspace B's exchange failed, npm could incorrectly fall back to A's token instead of the original credentials or reporting ENEEDAUTH when no credentials were available. This PR clears the previous exchanged token before every subsequent OIDC attempt, including attempts that fail or are skipped.

Exchanged tokens now use the cli config namespace instead of user. The cli layer is non-persistable, so temporary tokens do not overwrite user credentials (in memory) and cannot be included when saving user configuration. Token deletion also invalidates cached flat options so a stale copy cannot remain available to subsequent operations.

Validation

All 1,439 assertions passed: 422 across the affected OIDC and command tests, plus 1,017 in the config workspace.

node node_modules/tap/bin/run.js --no-coverage --reporter=classic test/lib/utils/oidc.js test/lib/commands/dist-tag.js test/lib/commands/publish.js test/lib/commands/stage/index.js
(cd workspaces/config && node ../../node_modules/tap/bin/run.js --no-coverage --reporter=classic test)

The workspace token-reuse and config cache regression tests were also verified to fail against the existing implementation with the fixes stashed.

Use package-scoped OIDC exchange tokens for dist-tag operations and clear the previous token before each subsequent exchange. Keep temporary credentials in the non-persistable CLI config layer and invalidate flattened options when config values are deleted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 15207d1d-40b3-4973-9371-b7aba1e286fb
@reggi
reggi requested a review from a team as a code owner September 24, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants