Passa al contenuto principale
Versione: Prossimo

Authentication Settings

The settings on this page contain sensitive credentials and are stored in INI-formatted files. Do not commit these files to your repository.

For non-sensitive settings (proxy, SSL, registries, etc.), see Settings (pnpm-workspace.yaml).

Auth file locations

pnpm reads authentication settings from the following files, in order of priority (highest first):

  1. <workspace root>/.npmrc — project-level auth. This file should be listed in .gitignore.
  2. <pnpm config>/auth.ini — the primary user-level auth file. pnpm login writes tokens here.
  3. ~/.npmrc — read as a fallback for easier migration from npm. Use the npmrcAuthFile setting to point to a different file.

The <pnpm config> directory is:

  • If the $XDG_CONFIG_HOME env variable is set: $XDG_CONFIG_HOME/pnpm/
  • On Windows: ~/AppData/Local/pnpm/config/
  • On macOS: ~/Library/Preferences/pnpm/
  • On Linux: ~/.config/pnpm/

Authentication Settings

<URL>:_authToken

Definisci il token del portatore di autenticazione da utilizzare quando si accede al registro. Ad esempio:

//registry.npmjs.org/:_authToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Puoi anche usare una variabile d'ambiente. Ad esempio:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

<URL>:tokenHelper

Un token helper è un eseguibile che emette un token di autenticazione. Può essere usato in situazioni in cui authToken non è un valore costante ma è qualcosa che si aggiorna regolarmente, in cui uno script o un altro strumento può usare un token di aggiornamento esistente per ottenere un nuovo token di accesso.

La configurazione per il percorso dell'helper deve essere un percorso assoluto, senza argomenti. Per essere sicuro, è consentito impostare questo valore solo nell'utente .npmrc. In caso contrario, un progetto potrebbe inserire un valore in .npmrc locale di un progetto ed eseguire eseguibili arbitrari.

Impostazione di un token helper per il registro predefinito:

tokenHelper=/home/ivan/token-generator

Impostazione di un token helper per il registro specificato:

//registry.corp.com:tokenHelper=/home/ivan/token-generator

Certificate Settings

ca

  • Predefinito: Il certificato CA di npm
  • Tipo: Stringa, Array o null

Il certificato di firma dell'autorità di certificazione considerato attendibile per le connessioni SSL al registro. I valori devono essere in formato PEM (ovvero "X.509 codificato in base-64 (.CER)"). Ad esempio:

ca="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"

Imposta a null per consentire solo ai registrar noti o un certificato CA specifico di considerare attendibile solo quella specifica autorità di firma.

È possibile considerare attendibili più CA specificando una serie di certificati:

ca[]="..."
ca[]="..."

See also the strictSsl setting.

cafile

  • Default: null
  • Tipo: percorso

Un percorso a un file contenente una o più autorità di certificazione che firmano certificati. Simile all'impostazione ca, ma permette più CA, così come per le informazioni CA da memorizzare in un file invece di essere specificato tramite CLI.

<URL>:cafile

Define the path to a Certificate Authority file to use when accessing the specified registry. Ad esempio:

//registry.npmjs.org/:cafile=ca-cert.pem

<URL>:ca

Added in: v10.25.0

Define an inline Certificate Authority certificate for the specified registry. The value must be PEM-encoded, like the global ca setting, but it only applies to the matching registry URL.

//registry.example.com/:ca=-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----

cert

  • Default: null
  • Tipo: Stringa

Un certificato client da passare quando si accede al registro. I valori devono essere in formato PEM (ovvero "X.509 codificato in base-64 (.CER)"). Ad esempio:

cert="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"

It is not the path to a certificate file.

<URL>:cert

Added in: v10.25.0

Define an inline client certificate to use when accessing the specified registry. Esempio:

//registry.example.com/:cert=-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----

<URL>:certfile

Define the path to a certificate file to use when accessing the specified registry. Ad esempio:

//registry.npmjs.org/:certfile=server-cert.pem

key

  • Predefinito: null
  • Tipo: Stringa

Una chiave client da passare quando si accede al registro. I valori devono essere in formato PEM (ovvero "X.509 codificato in base-64 (.CER)"). Ad esempio:

key="-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----"

It is not the path to a key file. Use <URL>&#58;keyfile if you need to reference the file system instead of inlining the key.

Questa impostazione contiene informazioni sensibili. Non scriverlo in un file .npmrc locale di cui hai effettuato il commit nel repository.

<URL>:key

Added in: v10.25.0

Define an inline client key for the specified registry URL.

//registry.example.com/:key=-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----

<URL>:keyfile

Define the path to a client key file to use when accessing the specified registry. Ad esempio:

//registry.npmjs.org/:keyfile=server-key.pem