Skip to content

Commit 1c249b3

Browse files
committed
fix: mechanism properties
1 parent 0e0bdd4 commit 1c249b3

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.evergreen/run-oidc-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ MONGODB_URI_SINGLE="${MONGODB_URI}/?authMechanism=MONGODB-OIDC&authMechanismProp
1010
echo $MONGODB_URI_SINGLE
1111

1212
export MONGODB_URI="$MONGODB_URI_SINGLE"
13+
expoort OIDC_TOKEN_DIR=${OIDC_TOKEN_DIR}
1314

1415
npm run check:oidc

src/cmap/auth/mongo_credentials.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ export class MongoCredentials {
117117
}
118118

119119
if (this.mechanism === AuthMechanism.MONGODB_OIDC && !this.mechanismProperties.ALLOWED_HOSTS) {
120-
this.mechanismProperties.ALLOWED_HOSTS = DEFAULT_ALLOWED_HOSTS;
120+
this.mechanismProperties = {
121+
...this.mechanismProperties,
122+
ALLOWED_HOSTS: DEFAULT_ALLOWED_HOSTS
123+
};
121124
}
122125

123126
Object.freeze(this.mechanismProperties);

test/manual/mongodb_oidc.prose.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
OIDCMechanismServerStep1,
1313
OIDCRequestTokenResult
1414
} from '../mongodb';
15-
import { request } from 'node:http';
1615

1716
describe('MONGODB-OIDC', function () {
1817
context('when running in the environment', function () {
@@ -351,11 +350,29 @@ describe('MONGODB-OIDC', function () {
351350
});
352351

353352
describe('3.3 Refresh Callback Returns Null', function () {
353+
before(function () {
354+
client = new MongoClient('mongodb://localhost/?authMechanism=MONGODB-OIDC', {
355+
authMechanismProperties: {
356+
REQUEST_TOKEN_CALLBACK: createRequestCallback('test_user1', 60),
357+
REFRESH_TOKEN_CALLBACK: () => {
358+
return Promise.resolve(null);
359+
}
360+
}
361+
});
362+
collection = client.db('test').collection('test');
363+
});
364+
354365
// Clear the cache.
355366
// Create request callback that returns a valid token that will expire in a minute, and a refresh callback that returns null.
356367
// Perform a find operation that succeeds.
357368
// Perform a find operation that fails.
358369
// Close the client.
370+
it('fails authentication on refresh', async function () {
371+
await collection.findOne();
372+
expect(async () => {
373+
await collection.findOne();
374+
}).to.throw;
375+
});
359376
});
360377

361378
describe('3.4 Request Callback Returns Invalid Data', function () {

0 commit comments

Comments
 (0)