You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3425e80
Browse filesBrowse the repository at this point in the historyBrowse files
feat(config): support an _auth setting for registry authentication (#12559)
Add an `_auth` setting that carries registry authentication as one
structured, URL-keyed value instead of many `//host/:_authToken=…` keys.
GitHub Actions silently drops env vars whose names contain `/`, `:`, or `.`
(and bash/zsh reject them outright), which broke the
`pnpm_config_//host/:_authToken=…` form on CI (#12314). The
`pnpm_config__auth` env var — the env projection of the `_auth` setting —
sidesteps the runner-level filter while preserving host scoping. The same
value can be set in the global pnpm config.yaml as a native YAML map.
Design:
- `_auth` is honored only from the env var and the global config.yaml —
never a project pnpm-workspace.yaml / .npmrc — so repo-controlled config
can never supply registry auth. The env var wins over the global config
on a conflicting key.
- The value is host-keyed: `{ "https://registry.example": { "@": {...},
"@org": {...} } }`. The host and credential arrive in one trusted value,
so the same entry is a safe source of registry routing — repo config
cannot redirect an env token to a different host. Routes inferred from
`_auth` are applied after workspace yaml (env/global wins over repo
config) and before PNPM_CONFIG_* so an explicit registry override still
wins — matching pnpm's "CLI > _auth > yaml" precedence.
- Reuses npm's deprecated `_auth` key name on purpose: pnpm reads the
structured form only from its own yaml (and the env projection), so it
never collides with npm's legacy `.npmrc` `_auth` scalar, and it is
already covered by the existing protected-settings redaction (prints as
`(protected)`).
- Only `authToken` is accepted (maps byte-for-byte to the existing
`//host/:_authToken` .npmrc key), so the parser is a thin adapter onto
the existing auth pipeline. The deprecated `basicAuth` / `username` +
`password` forms and `tokenHelper` are excluded — dropped with a warning.
- Malformed values, non-object shapes, non-URL keys, non-http(s) schemes,
URLs carrying credentials/query/fragment, invalid scopes, and unsupported
auth fields each push a distinct warning and are skipped without aborting
the load. Warnings never leak raw URL credentials.
Parity: implemented on both sides (TS CLI + pacquet). Both support the
single credential field `authToken`.
Closes#12314.
---------
Co-authored-by: Zoltan Kochan <[email protected]>
Added an `_auth` setting for configuring registry authentication as a single structured (URL-keyed) value. It can be set in the **global** pnpm config (`config.yaml`) or, for CI, via the `pnpm_config__auth` environment variable. The env form sidesteps the GitHub Actions / bash / zsh limitation that broke the existing `pnpm_config_//host/:_authToken=…` form (env var names containing `/`, `:`, or `.` are silently dropped). Closes pnpm/pnpm#12314.
7
+
8
+
The value is keyed by registry URL so each secret is explicitly bound to the host that may receive it. Registry URL keys must use `http` or `https` and must not include credentials, query strings, or fragments:
Within each registry URL, `@` means registry-wide/default credentials and package scopes like `@org` bind credentials to that scope on the same host. The only supported credential field is `authToken` (maps to `_authToken` / bearer auth); the deprecated `basicAuth` / `username` + `password` forms are intentionally not accepted here.
26
+
27
+
Each entry also infers a trusted registry route: `@`routes the default registry (and `pnpm add <pkg>` resolves there), and `@org` routes that scope. Because the credential and destination host arrive in one trusted value, repo-controlled `pnpm-workspace.yaml` or project `.npmrc` cannot redirect the token to a different host. `_auth` is honored **only** from the env var and the global config — it is ignored in a project `pnpm-workspace.yaml` / `.npmrc`, so repo-controlled config can never supply registry auth. Precedence: CLI flags (`--registry`, `--@scope:registry`) > `pnpm_config__auth` > global `config.yaml` `_auth` > `pnpm-workspace.yaml`.
28
+
29
+
Both `pnpm_config__auth` (lowercase, documented form) and `PNPM_CONFIG__AUTH` (all-caps, the shell convention some CI runners apply) are honored. If both are set, lowercase wins unless it is empty, in which case uppercase is used. The env var wins over the global `config.yaml` `_auth` on a conflicting key. `tokenHelper` is not supported in `_auth`. Parsing is strict: a malformed value (bad JSON, wrong shape, invalid registry URL or scope, an unsupported credential field) fails fast with an error rather than being silently dropped.
30
+
31
+
**Pacquet parity note:** the pacquet (Rust) port supports the same single credential field as the TS CLI: `authToken`.
0 commit comments