Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

How to authenticate npm with Azure DevOps Server 2019 artifacts using IIS Basic Authentication

We have an on-premise Azure DevOps Server 2019, hosted on a Windows Server 2012 R2 Datacenter VM and IIS 8.5 with Basic Authentication enabled. We've been using Azure Artifacts packaging and feeds to publish our NuGet packages and for that we use Windows Authentication (Developers use their active directory domain username and passwords). Now, I'm trying to setup using feeds for npm.

I created a new npm project using npm init, opened the containing folder in VS Code and created a .npmrc file as Azure Artifacts told me too, then tried to install a package from the upstream package. But I get the following error:


0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'sass-node'
1 verbose cli ]
2 info using npm@6.10.2
3 info using node@v12.9.0
4 verbose npm-session cfab4705708e8227
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 401 http://(redacted domain name):8080/tfs/PAP%20Projects/_packaging/pap-front-end/npm/registry/sass-node 52ms
8 silly fetchPackageMetaData error for sass-node@latest Unable to authenticate, need: Bearer, Basic realm="http://(redacted local domain name):8080/tfs", Negotiate, NTLM
9 timing stage:rollbackFailedOptional Completed in 0ms
10 timing stage:runTopLevelLifecycles Completed in 99ms
11 verbose stack Error: Unable to authenticate, need: Bearer, Basic realm="http://(redacted local domain name):8080/tfs", Negotiate, NTLM
11 verbose stack     at C:Program Files
odejs
ode_modules
pm
ode_modules
pm-registry-fetchcheck-response.js:94:17
11 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:85:5)
12 verbose statusCode 401
13 verbose pkgid sass-node@latest
14 verbose cwd C:Usersa.taravaticode
pm-test
15 verbose Windows_NT 10.0.17763
16 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "sass-node"
17 verbose node v12.9.0
18 verbose npm  v6.10.2
19 error code E401
20 error Unable to authenticate, your authentication token seems to be invalid.
21 error To correct this please trying logging in again with:
21 error     npm login
22 verbose exit [ 1, true ]


I didn't redact some parts on purpose, in case there exists an issue regarding them. It's notable that I search the internet and found several Q&A especially in stackoverflow and they were close to my problem but the answers were no use to me. Overall, I got the following tips:

  • When Basic Authentication is enabled you can't use PAT
  • You should encode windows password with Base64 then put it in .npmrc along with username.

I've tried them but still no luck. I'm also not sure about the following:

  • Should I put just username or should I use domainusername or username@domain formats?
  • Should I put Base64 encoded string of my password in .npmrc?
  • Is there a problem with the URL? the Domain? the Protocol? the collection name or feed name?
  • Is it possible that as long as we keep Basic Authentication enabled there won't be any chance to set this up?

Also, whenever I try to use npm login it prompts for username, password and email but then return a 400 error.

question from:https://stackoverflow.com/questions/65934027/how-to-authenticate-npm-with-azure-devops-server-2019-artifacts-using-iis-basic

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...