Skip to content

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

@jenseng

Description

@jenseng

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions