Skip to content

Commit e58f02f

Browse files
fritzywraithgar
authored andcommitted
feat: warn on config --auth-type=sso/saml/oauth, undeprecate --auth-type
1 parent c6c4ba3 commit e58f02f

File tree

7 files changed

+78
-35
lines changed

7 files changed

+78
-35
lines changed

docs/content/commands/npm-adduser.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ npm init --scope=@foo --yes
9494

9595
* Default: "legacy"
9696
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
97-
* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
98-
a future version of npm in favor of web-based login.
9997

100-
What authentication strategy to use with `adduser`/`login`.
98+
NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
99+
future version.
100+
101+
What authentication strategy to use with `login`.
101102

102103
Pass `webauthn` to use a web-based login.
103104

docs/content/using-npm/config.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,21 @@ exit code.
215215
<!-- automatically generated, do not edit manually -->
216216
<!-- see lib/utils/config/definitions.js -->
217217

218+
#### `auth-type`
219+
220+
* Default: "legacy"
221+
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
222+
223+
NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
224+
future version.
225+
226+
What authentication strategy to use with `login`.
227+
228+
Pass `webauthn` to use a web-based login.
229+
230+
<!-- automatically generated, do not edit manually -->
231+
<!-- see lib/utils/config/definitions.js -->
232+
218233
#### `before`
219234

220235
* Default: null
@@ -1905,20 +1920,6 @@ When set to `dev` or `development`, this is an alias for `--include=dev`.
19051920
<!-- automatically generated, do not edit manually -->
19061921
<!-- see lib/utils/config/definitions.js -->
19071922

1908-
#### `auth-type`
1909-
1910-
* Default: "legacy"
1911-
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
1912-
* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
1913-
a future version of npm in favor of web-based login.
1914-
1915-
What authentication strategy to use with `adduser`/`login`.
1916-
1917-
Pass `webauthn` to use a web-based login.
1918-
1919-
<!-- automatically generated, do not edit manually -->
1920-
<!-- see lib/utils/config/definitions.js -->
1921-
19221923
#### `cache-max`
19231924

19241925
* Default: Infinity

lib/utils/config/definitions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = definitions
33

44
const Definition = require('./definition.js')
55

6+
const log = require('../log-shim')
67
const { version: npmVersion } = require('../../../package.json')
78
const ciDetect = require('@npmcli/ci-detect')
89
const ciName = ciDetect()
@@ -239,12 +240,24 @@ define('audit-level', {
239240
define('auth-type', {
240241
default: 'legacy',
241242
type: ['legacy', 'webauthn', 'sso', 'saml', 'oauth'],
243+
// deprecation in description rather than field, because not every value
244+
// is deprecated
242245
description: `
246+
NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a future version.
247+
243248
What authentication strategy to use with \`login\`.
244249
245250
Pass \`webauthn\` to use a web-based login.
246251
`,
247-
flatten,
252+
flatten (key, obj, flatOptions) {
253+
flatOptions.authType = obj[key]
254+
if (obj[key] === 'sso') {
255+
// no need to deprecate saml/oauth here, as sso-type will be set by these in
256+
// lib/auth/ and is deprecated already
257+
log.warn('config',
258+
'--auth-type=sso is will be removed in a future version.')
259+
}
260+
},
248261
})
249262

250263
define('before', {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* IMPORTANT
2+
* This snapshot file is auto-generated, but designed for humans.
3+
* It should be checked into source control and tracked carefully.
4+
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
5+
* Make sure to inspect the output below. Do not ignore changes!
6+
*/
7+
'use strict'
8+
exports[`test/lib/commands/adduser.js TAP auth-type sso warning > warning 1`] = `
9+
Object {
10+
"warn": Array [
11+
Array [
12+
"config",
13+
"--auth-type=sso is will be removed in a future version.",
14+
],
15+
],
16+
}
17+
`

tap-snapshots/test/lib/utils/config/definitions.js.test.cjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,11 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for auth-
254254
255255
* Default: "legacy"
256256
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
257-
* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
258-
a future version of npm in favor of web-based login.
259257
260-
What authentication strategy to use with \`adduser\`/\`login\`.
258+
NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
259+
future version.
260+
261+
What authentication strategy to use with \`login\`.
261262
262263
Pass \`webauthn\` to use a web-based login.
263264
`

tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ exit code.
8888
<!-- automatically generated, do not edit manually -->
8989
<!-- see lib/utils/config/definitions.js -->
9090
91+
#### \`auth-type\`
92+
93+
* Default: "legacy"
94+
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
95+
96+
NOTE: auth-type values "sso", "saml", and "oauth" will be removed in a
97+
future version.
98+
99+
What authentication strategy to use with \`login\`.
100+
101+
Pass \`webauthn\` to use a web-based login.
102+
103+
<!-- automatically generated, do not edit manually -->
104+
<!-- see lib/utils/config/definitions.js -->
105+
91106
#### \`before\`
92107
93108
* Default: null
@@ -1778,20 +1793,6 @@ When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`.
17781793
<!-- automatically generated, do not edit manually -->
17791794
<!-- see lib/utils/config/definitions.js -->
17801795
1781-
#### \`auth-type\`
1782-
1783-
* Default: "legacy"
1784-
* Type: "legacy", "webauthn", "sso", "saml", or "oauth"
1785-
* DEPRECATED: The SSO/SAML/OAuth methods are deprecated and will be removed in
1786-
a future version of npm in favor of web-based login.
1787-
1788-
What authentication strategy to use with \`adduser\`/\`login\`.
1789-
1790-
Pass \`webauthn\` to use a web-based login.
1791-
1792-
<!-- automatically generated, do not edit manually -->
1793-
<!-- see lib/utils/config/definitions.js -->
1794-
17951796
#### \`cache-max\`
17961797
17971798
* Default: Infinity

test/lib/commands/adduser.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ t.test('bad auth type', async t => {
7575
})
7676
})
7777

78+
t.test('auth-type sso warning', async t => {
79+
const { logs } = await loadMockNpm(t, {
80+
config: {
81+
'auth-type': 'sso',
82+
},
83+
})
84+
t.matchSnapshot({ warn: logs.warn }, 'warning')
85+
})
86+
7887
t.test('scoped login', async t => {
7988
const stdin = new stream.PassThrough()
8089
stdin.write('test-user\n')

0 commit comments

Comments
 (0)