Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for AzureAuthentication #7828

Draft
wants to merge 1 commit into
base: latest
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ tap-testdir*/
!/workspaces/libnpmsearch/
!/workspaces/libnpmteam/
!/workspaces/libnpmversion/

node_modules/
6 changes: 3 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; This file is automatically added by @npmcli/template-oss. Do not edit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to test accessing to a specific registry. This will be removed once it works.

package-lock=true
# Auto generated file from Gardener Plugin CentralFeedServiceAdoptionPlugin
registry=https://pkgs.dev.azure.com/msasg/bing_and_ipg/_packaging/bing_and_ipg_PublicPackages/npm/registry/
always-auth=true
62 changes: 62 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,47 @@ graph LR;
agent-base-->debug;
aggregate-error-->clean-stack;
aggregate-error-->indent-string;
azure-abort-controller-->tslib;
azure-core-auth-->azure-abort-controller["@azure/abort-controller"];
azure-core-auth-->azure-core-util["@azure/core-util"];
azure-core-auth-->tslib;
azure-core-client-->azure-abort-controller["@azure/abort-controller"];
azure-core-client-->azure-core-auth["@azure/core-auth"];
azure-core-client-->azure-core-rest-pipeline["@azure/core-rest-pipeline"];
azure-core-client-->azure-core-tracing["@azure/core-tracing"];
azure-core-client-->azure-core-util["@azure/core-util"];
azure-core-client-->azure-logger["@azure/logger"];
azure-core-client-->tslib;
azure-core-rest-pipeline-->azure-abort-controller["@azure/abort-controller"];
azure-core-rest-pipeline-->azure-core-auth["@azure/core-auth"];
azure-core-rest-pipeline-->azure-core-tracing["@azure/core-tracing"];
azure-core-rest-pipeline-->azure-core-util["@azure/core-util"];
azure-core-rest-pipeline-->azure-logger["@azure/logger"];
azure-core-rest-pipeline-->http-proxy-agent;
azure-core-rest-pipeline-->https-proxy-agent;
azure-core-rest-pipeline-->tslib;
azure-core-tracing-->tslib;
azure-core-util-->azure-abort-controller["@azure/abort-controller"];
azure-core-util-->tslib;
azure-identity-->azure-abort-controller["@azure/abort-controller"];
azure-identity-->azure-core-auth["@azure/core-auth"];
azure-identity-->azure-core-client["@azure/core-client"];
azure-identity-->azure-core-rest-pipeline["@azure/core-rest-pipeline"];
azure-identity-->azure-core-tracing["@azure/core-tracing"];
azure-identity-->azure-core-util["@azure/core-util"];
azure-identity-->azure-logger["@azure/logger"];
azure-identity-->azure-msal-browser["@azure/msal-browser"];
azure-identity-->azure-msal-node["@azure/msal-node"];
azure-identity-->events;
azure-identity-->jws;
azure-identity-->open;
azure-identity-->stoppable;
azure-identity-->tslib;
azure-logger-->tslib;
azure-msal-browser-->azure-msal-common["@azure/msal-common"];
azure-msal-node-->azure-msal-common["@azure/msal-common"];
azure-msal-node-->jsonwebtoken;
azure-msal-node-->uuid;
bin-links-->cmd-shim;
bin-links-->npm-normalize-package-bin;
bin-links-->proc-log;
Expand All @@ -288,6 +329,7 @@ graph LR;
cross-spawn-->shebang-command;
cross-spawn-->which;
debug-->ms;
ecdsa-sig-formatter-->safe-buffer;
encoding-->iconv-lite;
foreground-child-->cross-spawn;
foreground-child-->signal-exit;
Expand Down Expand Up @@ -315,6 +357,7 @@ graph LR;
ip-address-->jsbn;
ip-address-->sprintf-js;
is-cidr-->cidr-regex;
is-wsl-->is-docker;
isaacs-cliui-->string-width-cjs;
isaacs-cliui-->string-width;
isaacs-cliui-->strip-ansi-cjs;
Expand All @@ -323,6 +366,21 @@ graph LR;
isaacs-cliui-->wrap-ansi;
jackspeak-->isaacs-cliui["@isaacs/cliui"];
jackspeak-->pkgjs-parseargs["@pkgjs/parseargs"];
jsonwebtoken-->jws;
jsonwebtoken-->lodash.includes;
jsonwebtoken-->lodash.isboolean;
jsonwebtoken-->lodash.isinteger;
jsonwebtoken-->lodash.isnumber;
jsonwebtoken-->lodash.isplainobject;
jsonwebtoken-->lodash.isstring;
jsonwebtoken-->lodash.once;
jsonwebtoken-->ms;
jsonwebtoken-->semver;
jwa-->buffer-equal-constant-time;
jwa-->ecdsa-sig-formatter;
jwa-->safe-buffer;
jws-->jwa;
jws-->safe-buffer;
libnpmaccess-->nock;
libnpmaccess-->npm-package-arg;
libnpmaccess-->npm-registry-fetch;
Expand Down Expand Up @@ -463,6 +521,7 @@ graph LR;
npm-->ajv-formats;
npm-->ajv;
npm-->archy;
npm-->azure-identity["@azure/identity"];
npm-->cacache;
npm-->chalk;
npm-->ci-info;
Expand Down Expand Up @@ -698,6 +757,9 @@ graph LR;
npmcli-smoke-tests-->semver;
npmcli-smoke-tests-->tap;
npmcli-smoke-tests-->which;
open-->define-lazy-prop;
open-->is-docker;
open-->is-wsl;
p-map-->aggregate-error;
pacote-->cacache;
pacote-->fs-minipass;
Expand Down
16 changes: 15 additions & 1 deletion lib/commands/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Login extends BaseCommand {
async exec () {
const scope = this.npm.config.get('scope')
let registry = this.npm.config.get('registry')
let authType = this.npm.config.get('auth-type')

console.log('scope:', scope)
console.log('registry:', registry)
console.log('authType:', authType)

if (scope) {
const scopedRegistry = this.npm.config.get(`${scope}:registry`)
Expand All @@ -24,7 +29,16 @@ class Login extends BaseCommand {
}
}

const creds = this.npm.config.getCredentialsByURI(registry)
if (authType == 'azureauth') {
this.npm.config.delete('_token', 'user') // prevent legacy pollution
if (await this.npm.config.getCredentialsByAzureAuth(registry)) {
log.notice('', `Logged in on ${replaceInfo(registry)}`)
return;
}
return;
}

const creds = this.npm.config.getCredentialsByURI(registry);

log.notice('', `Log in on ${replaceInfo(registry)}`)

Expand Down
58 changes: 58 additions & 0 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@
/*
!/.gitignore
# Allow all bundled deps
!/@azure/
/@azure/*
!/@azure/abort-controller
!/@azure/core-auth
!/@azure/core-auth/node_modules/
/@azure/core-auth/node_modules/*
!/@azure/core-auth/node_modules/@azure/
/@azure/core-auth/node_modules/@azure/*
!/@azure/core-auth/node_modules/@azure/abort-controller
!/@azure/core-client
!/@azure/core-client/node_modules/
/@azure/core-client/node_modules/*
!/@azure/core-client/node_modules/@azure/
/@azure/core-client/node_modules/@azure/*
!/@azure/core-client/node_modules/@azure/abort-controller
!/@azure/core-rest-pipeline
!/@azure/core-rest-pipeline/node_modules/
/@azure/core-rest-pipeline/node_modules/*
!/@azure/core-rest-pipeline/node_modules/@azure/
/@azure/core-rest-pipeline/node_modules/@azure/*
!/@azure/core-rest-pipeline/node_modules/@azure/abort-controller
!/@azure/core-tracing
!/@azure/core-util
!/@azure/core-util/node_modules/
/@azure/core-util/node_modules/*
!/@azure/core-util/node_modules/@azure/
/@azure/core-util/node_modules/@azure/*
!/@azure/core-util/node_modules/@azure/abort-controller
!/@azure/identity
!/@azure/logger
!/@azure/msal-browser
!/@azure/msal-common
!/@azure/msal-node
!/@isaacs/
/@isaacs/*
!/@isaacs/cliui
Expand Down Expand Up @@ -68,6 +101,7 @@
!/bin-links
!/binary-extensions
!/brace-expansion
!/buffer-equal-constant-time
!/cacache
!/cacache/node_modules/
/cacache/node_modules/*
Expand Down Expand Up @@ -96,12 +130,15 @@
!/debug/node_modules/
/debug/node_modules/*
!/debug/node_modules/ms
!/define-lazy-prop
!/diff
!/eastasianwidth
!/ecdsa-sig-formatter
!/emoji-regex
!/encoding
!/env-paths
!/err-code
!/events
!/exponential-backoff
!/fastest-levenshtein
!/foreground-child
Expand All @@ -121,16 +158,32 @@
!/ip-address
!/ip-regex
!/is-cidr
!/is-docker
!/is-fullwidth-code-point
!/is-lambda
!/is-wsl
!/isexe
!/jackspeak
!/jsbn
!/json-parse-even-better-errors
!/json-stringify-nice
!/jsonparse
!/jsonwebtoken
!/jsonwebtoken/node_modules/
/jsonwebtoken/node_modules/*
!/jsonwebtoken/node_modules/jwa
!/jsonwebtoken/node_modules/jws
!/just-diff-apply
!/just-diff
!/jwa
!/jws
!/lodash.includes
!/lodash.isboolean
!/lodash.isinteger
!/lodash.isnumber
!/lodash.isplainobject
!/lodash.isstring
!/lodash.once
!/lru-cache
!/make-fetch-happen
!/minimatch
Expand Down Expand Up @@ -196,6 +249,7 @@
/npm-registry-fetch/node_modules/*
!/npm-registry-fetch/node_modules/minizlib
!/npm-user-validate
!/open
!/p-map
!/package-json-from-dist
!/pacote
Expand All @@ -216,6 +270,7 @@
!/read
!/retry
!/rimraf
!/safe-buffer
!/safer-buffer
!/semver
!/shebang-command
Expand All @@ -234,6 +289,7 @@
!/spdx-license-ids
!/sprintf-js
!/ssri
!/stoppable
!/string-width-cjs
!/string-width
!/strip-ansi-cjs
Expand All @@ -250,6 +306,7 @@
!/text-table
!/tiny-relative-date
!/treeverse
!/tslib
!/tuf-js
!/tuf-js/node_modules/
/tuf-js/node_modules/*
Expand All @@ -267,6 +324,7 @@
!/unique-filename
!/unique-slug
!/util-deprecate
!/uuid
!/validate-npm-package-license
!/validate-npm-package-license/node_modules/
/validate-npm-package-license/node_modules/*
Expand Down
Loading