Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@github.com>2022-07-12 02:47:40 +0300
committerGar <wraithgar@github.com>2022-07-12 21:34:35 +0300
commite58f02f5e8263bf86ae1f07a863098d445e6d0cd (patch)
tree333aba1e632c599b16ad37b1eff3d845d96bae5f
parentc6c4ba3b62e2a0896a48329f4c7e13d9e44a2f80 (diff)
feat: warn on config --auth-type=sso/saml/oauth, undeprecate --auth-type
-rw-r--r--docs/content/commands/npm-adduser.md7
-rw-r--r--docs/content/using-npm/config.md29
-rw-r--r--lib/utils/config/definitions.js15
-rw-r--r--tap-snapshots/test/lib/commands/adduser.js.test.cjs17
-rw-r--r--tap-snapshots/test/lib/utils/config/definitions.js.test.cjs7
-rw-r--r--tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs29
-rw-r--r--test/lib/commands/adduser.js9
7 files changed, 78 insertions, 35 deletions
diff --git a/docs/content/commands/npm-adduser.md b/docs/content/commands/npm-adduser.md
index 9f7caeb9c..aaa62e1b9 100644
--- a/docs/content/commands/npm-adduser.md
+++ b/docs/content/commands/npm-adduser.md
@@ -94,10 +94,11 @@ npm init --scope=@foo --yes
* Default: "legacy"
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
-* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
- a future version of npm in favor of web-based login.
-What authentication strategy to use with `adduser`/`login`.
+NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
+future version.
+
+What authentication strategy to use with `login`.
Pass `webauthn` to use a web-based login.
diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md
index 3fb431402..debb25636 100644
--- a/docs/content/using-npm/config.md
+++ b/docs/content/using-npm/config.md
@@ -215,6 +215,21 @@ exit code.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
+#### `auth-type`
+
+* Default: "legacy"
+* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
+
+NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
+future version.
+
+What authentication strategy to use with `login`.
+
+Pass `webauthn` to use a web-based login.
+
+<!-- automatically generated, do not edit manually -->
+<!-- see lib/utils/config/definitions.js -->
+
#### `before`
* Default: null
@@ -1905,20 +1920,6 @@ When set to `dev` or `development`, this is an alias for `--include=dev`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
-#### `auth-type`
-
-* Default: "legacy"
-* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
-* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
- a future version of npm in favor of web-based login.
-
-What authentication strategy to use with `adduser`/`login`.
-
-Pass `webauthn` to use a web-based login.
-
-<!-- automatically generated, do not edit manually -->
-<!-- see lib/utils/config/definitions.js -->
-
#### `cache-max`
* Default: Infinity
diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js
index f58a26768..e654c6b99 100644
--- a/lib/utils/config/definitions.js
+++ b/lib/utils/config/definitions.js
@@ -3,6 +3,7 @@ module.exports = definitions
const Definition = require('./definition.js')
+const log = require('../log-shim')
const { version: npmVersion } = require('../../../package.json')
const ciDetect = require('@npmcli/ci-detect')
const ciName = ciDetect()
@@ -239,12 +240,24 @@ define('audit-level', {
define('auth-type', {
default: 'legacy',
type: ['legacy', 'webauthn', 'sso', 'saml', 'oauth'],
+ // deprecation in description rather than field, because not every value
+ // is deprecated
description: `
+ NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a future version.
+
What authentication strategy to use with \`login\`.
Pass \`webauthn\` to use a web-based login.
`,
- flatten,
+ flatten (key, obj, flatOptions) {
+ flatOptions.authType = obj[key]
+ if (obj[key] === 'sso') {
+ // no need to deprecate saml/oauth here, as sso-type will be set by these in
+ // lib/auth/ and is deprecated already
+ log.warn('config',
+ '--auth-type=sso is will be removed in a future version.')
+ }
+ },
})
define('before', {
diff --git a/tap-snapshots/test/lib/commands/adduser.js.test.cjs b/tap-snapshots/test/lib/commands/adduser.js.test.cjs
new file mode 100644
index 000000000..ba27a6a78
--- /dev/null
+++ b/tap-snapshots/test/lib/commands/adduser.js.test.cjs
@@ -0,0 +1,17 @@
+/* IMPORTANT
+ * This snapshot file is auto-generated, but designed for humans.
+ * It should be checked into source control and tracked carefully.
+ * Re-generate by setting TAP_SNAPSHOT=1 and running tests.
+ * Make sure to inspect the output below. Do not ignore changes!
+ */
+'use strict'
+exports[`test/lib/commands/adduser.js TAP auth-type sso warning > warning 1`] = `
+Object {
+ "warn": Array [
+ Array [
+ "config",
+ "--auth-type=sso is will be removed in a future version.",
+ ],
+ ],
+}
+`
diff --git a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
index 19909d8c5..5a06f2c4b 100644
--- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
+++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
@@ -254,10 +254,11 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for auth-
* Default: "legacy"
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
-* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
- a future version of npm in favor of web-based login.
-What authentication strategy to use with \`adduser\`/\`login\`.
+NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
+future version.
+
+What authentication strategy to use with \`login\`.
Pass \`webauthn\` to use a web-based login.
`
diff --git a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
index 9d95aa952..a06f53012 100644
--- a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
+++ b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
@@ -88,6 +88,21 @@ exit code.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
+#### \`auth-type\`
+
+* Default: "legacy"
+* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
+
+NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
+future version.
+
+What authentication strategy to use with \`login\`.
+
+Pass \`webauthn\` to use a web-based login.
+
+<!-- automatically generated, do not edit manually -->
+<!-- see lib/utils/config/definitions.js -->
+
#### \`before\`
* Default: null
@@ -1778,20 +1793,6 @@ When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
-#### \`auth-type\`
-
-* Default: "legacy"
-* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
-* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
- a future version of npm in favor of web-based login.
-
-What authentication strategy to use with \`adduser\`/\`login\`.
-
-Pass \`webauthn\` to use a web-based login.
-
-<!-- automatically generated, do not edit manually -->
-<!-- see lib/utils/config/definitions.js -->
-
#### \`cache-max\`
* Default: Infinity
diff --git a/test/lib/commands/adduser.js b/test/lib/commands/adduser.js
index ca07199b2..7c7079394 100644
--- a/test/lib/commands/adduser.js
+++ b/test/lib/commands/adduser.js
@@ -75,6 +75,15 @@ t.test('bad auth type', async t => {
})
})
+t.test('auth-type sso warning', async t => {
+ const { logs } = await loadMockNpm(t, {
+ config: {
+ 'auth-type': 'sso',
+ },
+ })
+ t.matchSnapshot({ warn: logs.warn }, 'warning')
+})
+
t.test('scoped login', async t => {
const stdin = new stream.PassThrough()
stdin.write('test-user\n')