Skip to content
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

[FEATURE] registry-scoped certfile and keyfile options #118

Closed
jenseng opened this issue Apr 15, 2022 · 0 comments · Fixed by #125
Closed

[FEATURE] registry-scoped certfile and keyfile options #118

jenseng opened this issue Apr 15, 2022 · 0 comments · Fixed by #125

Comments

@jenseng
Copy link
Contributor

jenseng commented Apr 15, 2022

What

Add support for registry-scoped certfile and keyfile options, e.g.

{
  "//my.registry.example/npm/:certfile": "~/.secret/stuff.crt",
  "//my.registry.example/npm/:keyfile": "~/.secret/stuff.key"
}

Why

  1. Currently you can only set a cert and key at the top level, which means it could be used in connections against any registry. If your options are coming from @npmcli/config, then there's not a good way to control this. Ideally a client certificate would only be presented to the registry that actually needs it, and you should be able to use different ones depending on the registry.
  2. The current cert and key options are the actual contents of the cert/key, rather than paths to them. If your options are coming from @npmcli/config, and the cert/key are auto-generated elsewhere, you need to then keep your use .npmrc in sync with that process or specify them as env vars. Both options potentially weaken security (e.g. could be accidentally checked in, .npmrc might be readable by other users, key could be extracted from /proc/<pid>/environ, etc.).

Current Workarounds

All the workarounds are problematic, and get even more complicated in dual-publishing scenarios. For example, you might want to scope the (bogus) credentials, but that can't be done via env vars due to this bug.

Notes

  1. I'd be happy to put together PRs around this if the idea is acceptable. A corresponding change would likely also be needed to getCredentialsByURI/etc. in @npmcli/config
  2. This feature is related to [FEATURE] Raise ENEEDAUTH error if doing a write to something other than login #38 and [BUG] ENEEDAUTH when authenticating against a registry via mTLS cli#4765 in the sense that these could be considered new authN-related options, i.e. custom registry authN could solely be done via mTLS, in which case we shouldn't throw ENEEDAUTH if these are set but token/credentials are not.
jenseng added a commit to jenseng/npm-registry-fetch that referenced this issue Jul 12, 2022
Closes npm#118
RFC: npm/rfcs#591

Add support for registry-scoped certfile and keyfile options, e.g.

```
{
  "//my.registry.example/npm/:certfile": "~/.secret/stuff.crt",
  "//my.registry.example/npm/:keyfile": "~/.secret/stuff.key"
}
```

Since these are registry-specific, they will override top-level cert and
key options (if set).

Like the top-level `cafile` option, these registry-scoped options are
silently ignored if invalid.
jenseng added a commit to jenseng/npm-registry-fetch that referenced this issue Jul 18, 2022
Closes npm#118
RFC: npm/rfcs#591

Add support for registry-scoped certfile and keyfile options, e.g.

```
{
  "//my.registry.example/npm/:certfile": "~/.secret/stuff.crt",
  "//my.registry.example/npm/:keyfile": "~/.secret/stuff.key"
}
```

Since these are registry-specific, they will override top-level cert and
key options (if set).

Like the top-level `cafile` option, these registry-scoped options are
silently ignored if invalid.
wraithgar pushed a commit that referenced this issue Jul 18, 2022
Closes #118
RFC: npm/rfcs#591

Add support for registry-scoped certfile and keyfile options, e.g.

```
{
  "//my.registry.example/npm/:certfile": "~/.secret/stuff.crt",
  "//my.registry.example/npm/:keyfile": "~/.secret/stuff.key"
}
```

Since these are registry-specific, they will override top-level cert and
key options (if set).

Like the top-level `cafile` option, these registry-scoped options are
silently ignored if invalid.
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 a pull request may close this issue.

1 participant