npm / npm

This repository is moving to: https://github.com/npm/cli
http://npm.community
17.54k stars 3.02k forks source link

NPM, TFS, and Windows Authentication #7557

Closed mikejr83 closed 9 years ago

mikejr83 commented 9 years ago

Until recently we were using a local install of Gitorious on our company's intranet to host tools/modules we were building with node. The consumers of the tools would use npm to install from the git repository.

npm install git://gitorious.corp.local/Project/repo@tag

Life was good. Then everyone decided on one source control system. We went with TFS 2013 because it supports each team's needs. One thing it doesn't do is support git/ssh. No biggie, I thought, we'll just use HTTP.

npm install http://tfs2013.corp.local:8080/tfs/DefaultCollection/TeamProject/_git/Repo

This causes npm an unhappy situation as well...

npm ERR! fetch failed http://tfs2013.corp.local:8080/tfs/DefaultCollection/TeamProject/_git/Repo
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401
npm ERR! fetch failed http://tfs2013.corp.local:8080/tfs/DefaultCollection/TeamProject/_git/Repo
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401

I fired up wireshark to get that response:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
        <style type="text/css">
            <!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;;}
-->
        </style>
    </head>
    <body>
        <div id="header">
            <h1>Server Error</h1>
        </div>
        <div id="content">
            <div class="content-container">
                <fieldset>
                    <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
                    <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
                </fieldset>
            </div>
        </div>
    </body>
</html>

So our TFS git repo uses windows auth / NTLM. How can I get npm pass through my credentials? I already setup git to use wincred? Is there a value I can set in npmrc for credentials? Is this not supported? Can this be supported? :)

othiym23 commented 9 years ago

Sounds like you need a cntlm proxy! The best way to get support for NTLM in npm is to bug the request team until they agree to figure it out for all of us. ;) npm doesn't handle details of proxying or tunneling itself.

othiym23 commented 9 years ago

Here's a pretty decent writeup of getting up and running with cntlm.