From a8ae17775a24ccbaf4570530d7433e0d290b3793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=B8ller=20Ellehauge?= Date: Wed, 1 Jun 2022 23:11:58 +0200 Subject: [PATCH] feat: Add `--auth-type=webauthn` flag (#4931) * feat: Add --use-webauth flag * Add docs * Switch from a separate flag to a variation of auth-type * Update snapshot --- docs/content/commands/npm-adduser.md | 14 ++++++++++++++ docs/content/using-npm/config.md | 8 +++++--- lib/commands/adduser.js | 2 ++ lib/utils/config/definitions.js | 6 ++++-- .../test/lib/load-all-commands.js.test.cjs | 2 ++ tap-snapshots/test/lib/npm.js.test.cjs | 2 ++ .../test/lib/utils/config/definitions.js.test.cjs | 8 +++++--- .../test/lib/utils/config/describe-all.js.test.cjs | 8 +++++--- 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/docs/content/commands/npm-adduser.md b/docs/content/commands/npm-adduser.md index 06eeb379c4dd8..9f7caeb9cdc90 100644 --- a/docs/content/commands/npm-adduser.md +++ b/docs/content/commands/npm-adduser.md @@ -87,6 +87,20 @@ npm init --scope=@foo --yes ``` + + + +#### `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. + diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index 12b508582af1c..4e9e67d970ba2 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -1891,12 +1891,14 @@ When set to `dev` or `development`, this is an alias for `--include=dev`. #### `auth-type` * Default: "legacy" -* Type: "legacy", "sso", "saml", or "oauth" -* DEPRECATED: This method of SSO/SAML/OAuth is deprecated and will be removed - in a future version of npm in favor of web-based login. +* 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. + diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index 755abea8eb9eb..cf467b7a73a5e 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -3,6 +3,7 @@ const replaceInfo = require('../utils/replace-info.js') const BaseCommand = require('../base-command.js') const authTypes = { legacy: require('../auth/legacy.js'), + webauthn: require('../auth/legacy.js'), oauth: require('../auth/oauth.js'), saml: require('../auth/saml.js'), sso: require('../auth/sso.js'), @@ -14,6 +15,7 @@ class AddUser extends BaseCommand { static params = [ 'registry', 'scope', + 'auth-type', ] static ignoreImplicitWorkspace = true diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 92fbbd1e6dc20..4032c552e24bb 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -238,13 +238,15 @@ define('audit-level', { define('auth-type', { default: 'legacy', - type: ['legacy', 'sso', 'saml', 'oauth'], + type: ['legacy', 'webauthn', 'sso', 'saml', 'oauth'], deprecated: ` - This method of SSO/SAML/OAuth is deprecated and will be removed in + The SSO/SAML/OAuth methods are deprecated and will be removed in a future version of npm in favor of web-based login. `, description: ` What authentication strategy to use with \`adduser\`/\`login\`. + + Pass \`webauthn\` to use a web-based login. `, flatten, }) diff --git a/tap-snapshots/test/lib/load-all-commands.js.test.cjs b/tap-snapshots/test/lib/load-all-commands.js.test.cjs index 7bcdd949b90da..802fa8de93516 100644 --- a/tap-snapshots/test/lib/load-all-commands.js.test.cjs +++ b/tap-snapshots/test/lib/load-all-commands.js.test.cjs @@ -33,6 +33,7 @@ npm adduser Options: [--registry ] [--scope <@scope>] +[--auth-type ] aliases: login, add-user @@ -523,6 +524,7 @@ npm adduser Options: [--registry ] [--scope <@scope>] +[--auth-type ] aliases: login, add-user diff --git a/tap-snapshots/test/lib/npm.js.test.cjs b/tap-snapshots/test/lib/npm.js.test.cjs index d15cae4428216..b2443e8949959 100644 --- a/tap-snapshots/test/lib/npm.js.test.cjs +++ b/tap-snapshots/test/lib/npm.js.test.cjs @@ -190,6 +190,7 @@ All commands: Options: [--registry ] [--scope <@scope>] + [--auth-type ] aliases: login, add-user @@ -601,6 +602,7 @@ All commands: Options: [--registry ] [--scope <@scope>] + [--auth-type ] aliases: login, add-user 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 b12dccdb76c31..d67f3e6fe0bd7 100644 --- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs @@ -253,11 +253,13 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for auth- #### \`auth-type\` * Default: "legacy" -* Type: "legacy", "sso", "saml", or "oauth" -* DEPRECATED: This method of SSO/SAML/OAuth is deprecated and will be removed - in a future version of npm in favor of web-based login. +* 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. ` exports[`test/lib/utils/config/definitions.js TAP > config description for before 1`] = ` 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 cacbe96a74f35..853e758dcd600 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 @@ -1764,12 +1764,14 @@ When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`. #### \`auth-type\` * Default: "legacy" -* Type: "legacy", "sso", "saml", or "oauth" -* DEPRECATED: This method of SSO/SAML/OAuth is deprecated and will be removed - in a future version of npm in favor of web-based login. +* 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. +