Skip to content

Commit c528617

Browse files
authored
fix: include nonce in oidc request by default MONGOSH-1905 MONGOSH-1917 (#2269)
1 parent 3ee446a commit c528617

File tree

14 files changed

+119
-78
lines changed

14 files changed

+119
-78
lines changed

.github/workflows/cron-tasks.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ jobs:
1313
name: Update automatically generated files
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
with:
1818
# don't checkout a detatched HEAD
1919
ref: ${{ github.head_ref }}
2020

2121
# this is important so git log can pick up on
2222
# the whole history to generate the list of AUTHORS
23-
fetch-depth: '0'
23+
fetch-depth: "0"
2424

2525
- name: Set up Git
2626
run: |
2727
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
2828
git config --local user.name "github-actions[bot]"
2929
30-
- uses: actions/setup-node@v2
30+
- uses: actions/setup-node@v4
3131
with:
3232
node-version: ^16.x
33-
cache: 'npm'
33+
cache: "npm"
3434

3535
- name: Install npm@8
3636
run: |
@@ -50,41 +50,36 @@ jobs:
5050
run: |
5151
npm run update-authors
5252
git add AUTHORS \*/AUTHORS
53-
git commit --no-allow-empty -m "chore: update AUTHORS" || true
5453
5554
- name: Generate Error Documentation
5655
run: |
5756
npm run generate-error-overview
5857
mv error-overview.md error-overview.rst packages/errors/generated/
5958
npm run reformat
6059
git add packages/errors/generated
61-
git commit --no-allow-empty -m "chore: update error documentation" || true
6260
6361
- name: Regenerate Evergreen Config
6462
run: |
6563
npm run update-evergreen-config
6664
git add .evergreen.yml
67-
git commit --no-allow-empty -m "chore: update evergreen config" || true
6865
6966
- name: Update Security Test Summary
7067
run: |
7168
npm run update-security-test-summary
7269
git add docs/security-test-summary.md
73-
git commit --no-allow-empty -m "chore: update security test summary" || true
7470
7571
- name: Regenerate CLI usage text in README files
7672
run: |
7773
npm run update-cli-usage-text packages/*/*.md *.md
7874
git add packages/*/*.md *.md
79-
git commit --no-allow-empty -m "chore: update CLI usage text" || true
8075
8176
- name: Create pull request
8277
id: cpr
8378
uses: peter-evans/create-pull-request@v6
8479
with:
8580
commit-message: Update auto-generated files
8681
branch: ci/cron-tasks-update-files
87-
title: 'chore: update auto-generated files'
82+
title: "chore: update auto-generated files"
8883
body: |
8984
- Update auto-generated files
9085

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ variable. For detailed instructions for each of our supported platforms, please
9090
--oidcTrustedEndpoint Treat the cluster/database mongosh as a trusted endpoint
9191
--oidcIdTokenAsAccessToken Use ID tokens in place of access tokens for auth
9292
--oidcDumpTokens[=mode] Debug OIDC by printing tokens to mongosh's output [full|include-secrets]
93+
--oidcNoNonce Don't send a nonce argument in the OIDC auth request
9394

9495
DB Address Examples:
9596

package-lock.json

Lines changed: 62 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/arg-parser/src/arg-mapper.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,22 @@ describe('arg-mapper.mapCliToDriver', function () {
450450
});
451451
});
452452

453+
context('when cli args have oidcNoNonce', function () {
454+
const cliOptions: CliOptions = {
455+
oidcNoNonce: true,
456+
};
457+
458+
it('maps to oidc skipNonceInAuthCodeRequest', function () {
459+
expect(optionsTest(cliOptions)).to.deep.equal({
460+
driver: {
461+
oidc: {
462+
skipNonceInAuthCodeRequest: true,
463+
},
464+
},
465+
});
466+
});
467+
});
468+
453469
context('when cli args have browser', function () {
454470
it('maps to oidc command', function () {
455471
expect(optionsTest({ browser: '/usr/bin/browser' })).to.deep.equal({

packages/arg-parser/src/arg-mapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function setServerApi<Key extends keyof ServerApi>(
2929
const serverApi =
3030
typeof previousServerApi === 'string'
3131
? { version: previousServerApi }
32-
: { ...previousServerApi } ?? {};
32+
: { ...previousServerApi };
3333
serverApi[key] = value;
3434
return setDriver(i, 'serverApi', serverApi as Required<ServerApi>);
3535
}
@@ -237,6 +237,7 @@ const MAPPINGS: {
237237
v.split(',').filter(Boolean) as OIDCOptions['allowedFlows']
238238
),
239239
oidcIdTokenAsAccessToken: (i, v) => setOIDC(i, 'passIdTokenAsAccessToken', v),
240+
oidcNoNonce: (i, v) => setOIDC(i, 'skipNonceInAuthCodeRequest', v),
240241
browser: (i, v) =>
241242
setOIDC(i, 'openBrowser', typeof v === 'string' ? { command: v } : v),
242243
};

packages/arg-parser/src/cli-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ export interface CliOptions {
5656
oidcTrustedEndpoint?: boolean;
5757
oidcIdTokenAsAccessToken?: boolean;
5858
oidcDumpTokens?: boolean | 'redacted' | 'include-secrets';
59+
oidcNoNonce?: boolean;
5960
browser?: string | false;
6061
}

packages/cli-repl/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ of mongosh, visit https://www.mongodb.com/try/download/shell.
7575
--oidcTrustedEndpoint Treat the cluster/database mongosh as a trusted endpoint
7676
--oidcIdTokenAsAccessToken Use ID tokens in place of access tokens for auth
7777
--oidcDumpTokens[=mode] Debug OIDC by printing tokens to mongosh's output [full|include-secrets]
78+
--oidcNoNonce Don't send a nonce argument in the OIDC auth request
7879

7980
DB Address Examples:
8081

packages/cli-repl/src/arg-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const OPTIONS = {
6565
'norc',
6666
'oidcTrustedEndpoint',
6767
'oidcIdTokenAsAccessToken',
68+
'oidcNoNonce',
6869
'perfTests',
6970
'quiet',
7071
'retryWrites',

packages/cli-repl/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ export const USAGE = `
152152
--oidcDumpTokens[=mode] ${i18n.__(
153153
'cli-repl.args.oidcDumpTokens'
154154
)}
155+
--oidcNoNonce ${i18n.__(
156+
'cli-repl.args.oidcNoNonce'
157+
)}
155158
156159
${clr(i18n.__('cli-repl.args.dbAddressOptions'), 'mongosh:section-header')}
157160

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
36-
"@mongodb-js/oidc-mock-provider": "^0.10.0",
36+
"@mongodb-js/oidc-mock-provider": "^0.10.2",
3737
"@mongodb-js/prettier-config-devtools": "^1.0.1",
3838
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
3939
"@types/chai-as-promised": "^7.1.3",

0 commit comments

Comments
 (0)