Skip to content
Open
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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@mongosh/cli-repl": "2.5.8",
"@mongosh/service-provider-core": "3.6.1",
"@mongodb-js/oidc-plugin": "^2.0.4",
"@mongodb-js/oidc-plugin": "^2.0.5",
"strip-ansi": "^6.0.0"
},
"devDependencies": {
Expand Down
41 changes: 34 additions & 7 deletions packages/e2e-tests/test/e2e-oidc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,27 +181,54 @@ describe('OIDC auth e2e', function () {
);
}

for (const useNonce of [true, false]) {
describe(`with nonce=${useNonce}`, function () {
function* nonceTestParameters(): Generator<{
expectNonce: boolean;
provideNonce: boolean;
}> {
for (const expectNonce of [false, true]) {
for (const provideNonce of [false, true]) {
yield { expectNonce, provideNonce };
}
}
}

for (const { expectNonce, provideNonce } of nonceTestParameters()) {
describe(`with expectNonce=${expectNonce} provideNonce=${provideNonce}`, function () {
it('can successfully authenticate using OIDC Auth Code Flow', async function () {
const originalGetPayload = getTokenPayload;
getTokenPayload = async (metadata) => {
const result = await originalGetPayload(metadata);
if (provideNonce === false) {
result.payload.nonce = undefined;
}
return result;
};

const args = [
await testServer.connectionString(),
'--authenticationMechanism=MONGODB-OIDC',
'--oidcRedirectUri=http://localhost:0/',
`--browser=${fetchBrowserFixture}`,
];

if (!useNonce) {
if (!expectNonce) {
args.push('--oidcNoNonce');
}

shell = this.startTestShell({
args,
});
await shell.waitForPrompt();

await verifyUser(shell, 'testuser', 'testServer-group');
shell.assertNoErrors();
if (!expectNonce || provideNonce) {
await shell.waitForPrompt();

await verifyUser(shell, 'testuser', 'testServer-group');
shell.assertNoErrors();
} else {
expect(await shell.waitForAnyExit()).to.equal(1);
shell.assertContainsOutput(
'Error: invalid response encountered (caused by: JWT "nonce" (nonce) claim missing)'
);
}
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/service-provider-node-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@mongodb-js/devtools-connect": "^3.9.4",
"@mongodb-js/oidc-plugin": "^2.0.4",
"@mongodb-js/oidc-plugin": "^2.0.5",
"@mongosh/errors": "2.4.4",
"@mongosh/service-provider-core": "3.6.1",
"@mongosh/types": "^3.14.0",
Expand Down