diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2014-06-18 02:40:03 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-07-02 05:16:43 +0400 |
commit | 33dd0afcb3cc3dee90fbe32906d1b489b0cf05f0 (patch) | |
tree | 7acbf0bfa90c4c1406677c59a1016a7aced01e81 | |
parent | 4b85f1e3db16ecc6988a59782d1fe5a434da0eb1 (diff) |
scope token to the registry
-rw-r--r-- | lib/adduser.js | 9 | ||||
-rw-r--r-- | node_modules/npm-registry-client/lib/request.js | 5 | ||||
-rw-r--r-- | node_modules/npm-registry-client/package.json | 4 | ||||
-rw-r--r-- | test/tap/config-meta.js | 4 |
4 files changed, 14 insertions, 8 deletions
diff --git a/lib/adduser.js b/lib/adduser.js index 62e6ce0b8..8315809c5 100644 --- a/lib/adduser.js +++ b/lib/adduser.js @@ -2,6 +2,7 @@ module.exports = adduser var log = require("npmlog") + , url = require("url") , npm = require("./npm.js") , registry = npm.registry , read = require("read") @@ -133,7 +134,8 @@ function save (c, u, cb) { } npm.spinner.start() // save existing configs, but yank off for this PUT - registry.adduser(npm.config.get("registry"), u.u, u.p, u.e, function (er, doc) { + var uri = npm.config.get("registry") + registry.adduser(uri, u.u, u.p, u.e, function (er, doc) { npm.spinner.stop() if (er) return cb(er) registry.username = u.u @@ -143,9 +145,10 @@ function save (c, u, cb) { npm.config.del("_token", "user") npm.config.set("username", u.u, "user") npm.config.set("_password", u.p, "user") - // TODO: on-prem should move to scoped modules / multi-registry if (doc && doc.token) { - npm.config.set("_authToken", doc.token, "user") + var munged = url.parse(uri) + delete munged.protocol + npm.config.set(url.format(munged) + ":_authToken", doc.token, "user") } npm.config.set("email", u.e, "user") log.info("adduser", "Authorized user %s", u.u) diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js index 7521f718f..190fa5ccf 100644 --- a/node_modules/npm-registry-client/lib/request.js +++ b/node_modules/npm-registry-client/lib/request.js @@ -188,8 +188,9 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) { headers["user-agent"] = this.conf.get('user-agent') || 'node/' + process.version - // TODO: on-prem needs to move to scoped modules / multi-registry - var authToken = this.conf.get('_authToken') + var tokenKey = remote + ":_authToken" + this.log.silly("tokenKey", tokenKey) + var authToken = this.conf.get(tokenKey) if (authToken) headers.authorization = "Bearer " + authToken var p = this.conf.get('proxy') diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 0809c4c1a..284aac890 100644 --- a/node_modules/npm-registry-client/package.json +++ b/node_modules/npm-registry-client/package.json @@ -41,7 +41,7 @@ }, "homepage": "https://github.com/isaacs/npm-registry-client", "_id": "npm-registry-client@2.0.2", - "_shasum": "d0d8bbb8ff165a7d10caa22b76da77237fe0129a", - "_resolved": "git://github.com/npm/npm-registry-client#b6691a9ef44bc35b7e09f3e96abb97551287dc8b", + "_shasum": "ba353db91925e4122ab8fb9a9c67025be726c00b", + "_resolved": "git://github.com/npm/npm-registry-client#707cc5434b04d826dd1c03212a5e0721094ad84c", "_from": "git://github.com/npm/npm-registry-client#othiym23/multi-registry" } diff --git a/test/tap/config-meta.js b/test/tap/config-meta.js index 935438720..b116ca8a0 100644 --- a/test/tap/config-meta.js +++ b/test/tap/config-meta.js @@ -16,10 +16,12 @@ var CONFS = {} var DOC = {} var exceptions = [ + path.resolve(lib, "adduser.js"), path.resolve(lib, "config.js"), path.resolve(lib, "publish.js"), path.resolve(lib, "utils", "lifecycle.js"), - path.resolve(lib, "utils", "map-name-to-registry.js") + path.resolve(lib, "utils", "map-name-to-registry.js"), + path.resolve(nm, "npm-registry-client", "lib", "request.js") ] test("get files", function (t) { |