Azure Artifacts 私有 npm 源身份验证失败

Mic*_*ock 6 npm azure-devops azure-artifacts azure-devops-server azure-devops-server-2019

几个月前,我在 Azure Artifacts 中创建了一个私有 npm 源。使用此提要的身份验证工作正常。

最近,其他人开始使用此提要,但使用他们从 Azure Artifacts 生成的令牌进行身份验证对他们不起作用。安装 npm 时出现以下错误

npm 错误!无法进行身份验证,您的身份验证令牌似乎是

无效的。npm 错误!要更正此问题,请尝试再次登录:

npm 错误!登录

在 npm 调试日志中有这个错误

详细堆栈错误:无法进行身份验证,需要:承载,基本领域 =“{{redacted url}}”,NTLM


我们放在全局 .npmrc 文件中的身份验证令牌的结构似乎在 Azure Artifacts 中发生了变化

从:

; Treat this auth token like a password. Do not share it with anyone, including Microsoft support. This token expires on or before 27/02/2020.

; begin auth token

//{{redacted URL}}/_packaging/{{redacted user name}}/npm/registry/:_authToken={{redacted token string}}

//{redacted URL}}/_packaging/{{redacted user name}}/npm/:_authToken={{redacted token string}}

; end auth token
Run Code Online (Sandbox Code Playgroud)

; Treat this auth token like a password. Do not share it with anyone, including Microsoft support. This token expires on or before 14/04/2020.
; begin auth token
//{{redacted url}}/npm/registry/:username={{redacted username}}
//{{redacted url}}/npm/registry/:_password={{redacted password}}
//{{redacted url}}/npm/registry/:email=npm requires email to be set but doesn't use the value
//{{redacted url}}/_packaging/{{redacted username}}/npm/:username={{redacted user name}}
//{{redacted url}}/_packaging/{{redacted username}}/npm/:_password={{redacted password}}
//{{redacted url}}/_packaging/{{redacted username}}/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
Run Code Online (Sandbox Code Playgroud)

当使用第二个令牌(或者实际上是我现在从 Azure Artifacts 生成的任何令牌)时,我们不能npm install,我们得到上面显示的错误。如果其他人使用与我相同的令牌(以旧格式),这很好用。但是这个令牌很快就会过期。

我试过提供一个电子邮件地址而不是字符串“npm 需要设置电子邮件但不使用该值”,但这也不起作用。

这可能无关,但我们最近从 tfs 版本 16.131.28507.4 升级到 Azure Devops Server 版本 Dev17.M153.3。

有谁知道为什么身份验证令牌格式发生了变化?和/或如何使新令牌与我的私人提要一起使用?


npm 版本:6.13.0

节点版本:10.12.0

Azure Devops 服务器版本:Dev17.M153.3

Mic*_*ock 1

经过进一步调查并与 Microsoft Azure 支持人员交谈后,我们确定了导致问​​题的原因。

\n\n

如果 TFS (Azure Devops) 实例托管在运行 IIS 基本身份验证的计算机上,则为 Azure Artifacts 推出的新令牌格式将不再起作用。这可能仅适用于在本地自行托管 TFS 实例的人。

\n\n

唯一可用的解决方法是修改此新令牌,并将 TFS user\xe2\x80\x99s 用户名和 Base 64 编码密码放入令牌字符串中出现的两个位置的registry/:username=和字符串之后。registry/:_password=这并不理想,因为您实际上必须在构建服务器上以几乎纯文本的形式存储密码。\n但如果您确实需要启用 IIS 基本身份验证,那么现在这似乎是您唯一的选择。禁用此功能并使用不同的身份验证方案确实可以修复令牌身份验证,并且您可以避免执行上述操作。

\n