From 224a74d03d836efcf67bcf222dd6a3a6ceb99687 Mon Sep 17 00:00:00 2001 From: Himanshu Garg Date: Fri, 13 Dec 2024 16:24:34 +0530 Subject: [PATCH] fix(dal): Set authMechanism as per our environment config (#7285) --- libs/dal/src/dal.service.ts | 2 ++ libs/dal/src/types/auth.ts | 8 ++++++++ libs/dal/src/types/index.ts | 1 + 3 files changed, 11 insertions(+) create mode 100644 libs/dal/src/types/auth.ts diff --git a/libs/dal/src/dal.service.ts b/libs/dal/src/dal.service.ts index ed1c5bfd6e0..348f02c8e23 100644 --- a/libs/dal/src/dal.service.ts +++ b/libs/dal/src/dal.service.ts @@ -1,4 +1,5 @@ import mongoose, { Connection, ConnectOptions } from 'mongoose'; +import { AuthMechanism } from './types'; export const baseConfig: ConnectOptions = { // AUTO_CREATE_INDEXES is deprecated, use MONGO_AUTO_CREATE_INDEXES @@ -6,6 +7,7 @@ export const baseConfig: ConnectOptions = { maxIdleTimeMS: process.env.MONGO_MAX_IDLE_TIME_IN_MS ? Number(process.env.MONGO_MAX_IDLE_TIME_IN_MS) : 1000 * 30, maxPoolSize: process.env.MONGO_MAX_POOL_SIZE ? Number(process.env.MONGO_MAX_POOL_SIZE) : 50, minPoolSize: process.env.MONGO_MIN_POOL_SIZE ? Number(process.env.MONGO_MIN_POOL_SIZE) : 10, + authMechanism: (process.env.MONGO_AUTH_MECHANISM as AuthMechanism) || ('DEFAULT' as AuthMechanism), }; export class DalService { diff --git a/libs/dal/src/types/auth.ts b/libs/dal/src/types/auth.ts new file mode 100644 index 00000000000..050606a3d52 --- /dev/null +++ b/libs/dal/src/types/auth.ts @@ -0,0 +1,8 @@ +export type AuthMechanism = + | 'DEFAULT' + | 'MONGODB-CR' + | 'SCRAM-SHA-1' + | 'SCRAM-SHA-256' + | 'MONGODB-X509' + | 'GSSAPI' + | 'PLAIN'; diff --git a/libs/dal/src/types/index.ts b/libs/dal/src/types/index.ts index e05844d67f1..675e31f3453 100644 --- a/libs/dal/src/types/index.ts +++ b/libs/dal/src/types/index.ts @@ -2,3 +2,4 @@ export * from './enforce'; export * from './helpers'; export * from './results'; export * from './error.enum'; +export * from './auth';