【发布时间】:2020-04-07 19:28:56
【问题描述】:
几个月前,我在 Azure Artifacts 中创建了一个私有 npm 源。使用此提要进行身份验证工作正常。
最近其他人已开始使用此提要,但使用他们从 Azure Artifacts 生成的令牌进行身份验证对他们不起作用。 npm安装时出现以下错误
npm 错误!无法进行身份验证,您的身份验证令牌似乎是
无效。 npm 错误!要更正此问题,请尝试再次登录:
npm 错误! npm 登录
在 npm 调试日志中有这个错误
详细堆栈错误:无法验证,需要:Bearer,Basic realm="{{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
到
; 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
当使用第二个令牌(或者实际上是我现在从 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
【问题讨论】:
-
我昨天发布了一个与您类似的problem,并且我的 npm 调试日志显示了相同的错误语句。但是,它适用于一个提要,但不适用于另一个提要,并且它们都使用 npmrc 文件中的新身份验证令牌结构。如果你能找到更多关于它的信息,我会很乐意学习。
-
@methon.dagger 这很有趣。我们也有 2 个提要。我无法使用新的令牌格式从其中任何一个安装包。如果您在我做之前找到了如何解决这个问题,请告诉我们。我找不到任何有关此问题的 Microsoft 指南。
-
您可以尝试将
strict-ssl=false添加到全局 .npmrc 的末尾吗? (或运行 npm config set strict-ssl false)。我遇到了自签名证书错误。并通过添加strict-ssl=false修复。不知道它是否适用于您的情况? -
@LeviLu-MSFT 谢谢你的建议。不幸的是我已经尝试过了,我得到了同样的错误。我们也尝试过使用PAC 代码。您对代码格式发生变化的原因有任何见解吗?
-
@MichaelHancock U 我对格式更改知之甚少。我注意到这种代码格式允许用户同时使用密码和 PAT 进行身份验证。您是否尝试过使用您的域\用户名作为用户名,使用 base64_encoded_password 作为密码进行身份验证?
标签: npm azure-devops azure-artifacts azure-devops-server-2019 azure-devops-server