简体   繁体   English

什么是npm中的身份验证令牌?

[英]What are authentication tokens in npm?

I am learning to the npm package manager, but I am stuck to understand security tokens ( using this documentation ). 我正在向npm软件包管理器学习,但是我仍然想了解安全性令牌(使用文档)。

As we already know: when we login to any website, a session is created. 众所周知:登录任何网站时,都会创建一个会话。 So I understand that the tokens are sessions. 因此,我知道令牌是会话。 But after deleting the token, the npm login session is still active, which means token plays different role than the sessions in npm. 但是,删除令牌后,npm登录会话仍处于活动状态,这意味着令牌扮演的角色与npm中的会话不同。

Then: said documentation is saying that the tokens can also be used to use the packages outside the npm from the current login session. 然后:所述文档说,令牌也可以用于在当前登录会话的npm之外使用软件包。 Can anyone please tell me in more simple examples what tokens are in npm and how they are useful? 谁能在更简单的示例中告诉我npm中有什么令牌以及它们如何有用?

How it says: the tokens can also be used to use the packages outside the npm from the current login session. 怎么说: the tokens can also be used to use the packages outside the npm from the current login session.

Example 1: If you have a project with CI, the environment where you will execute your jobs, will not be logged into npm registry, so if you are working with private packages, you will not be able to download those packages. 示例1:如果您有一个带有CI的项目,则将在其中执行作业的环境不会登录到npm注册表中,因此,如果您使用的是私有软件包,则将无法下载这些软件包。 (when your job execute npm install, you will get 403 error for private packages). (当您的工作执行npm install时,私有软件包将出现403错误)。 Commonly, you will need to set an env variable with your npm token, like NPM_TOKEN="your npm token" 通常,您需要使用npm令牌设置一个env变量,例如NPM_TOKEN =“您的npm令牌”

Example 2: Other example could be when you create a docker container, your docker images will not have a session for npm, so if you run npm i inside your docker container, you will no be able to download the private packages. 示例2:另一个示例可能是当您创建docker容器时,您的docker映像将没有npm会话,因此,如果您在npm i容器中运行npm i ,则将无法下载私有软件包。

With authentication tokens, you will be able to access to your private packages without using npm login . 使用身份验证令牌,无需使用npm login即可访问您的私有软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM