From 4bb8671f267da5981d224d0ffab605b0327f224a Mon Sep 17 00:00:00 2001 From: Johan Castiblanco <51926076+johanv26@users.noreply.github.com> Date: Wed, 24 May 2023 18:46:07 -0500 Subject: [PATCH] fix!: use correct case for authsource mongo Update `authSource` keyword argument to `authsource` Authsource was configurated in camelcase. https://github.com/overhangio/tutor/blob/master/tutor/templates/apps/openedx/settings/partials/common_all.py#L16 Something I think is ok because pymongo uses it in camelcase. https://pymongo.readthedocs.io/en/3.10.1/api/pymongo/mongo_client.html However, the error was presented because edx-platform use another variable when credentials are provided **(LOWERCASE)**. https://github.com/openedx/edx-platform/blob/master/xmodule/mongo_utils.py#L72 Looking more , the `auth_source `is configured with another key name: `authsource` **(LOWERCASE)** from the kwargs. https://github.com/openedx/edx-platform/blob/master/xmodule/mongo_utils.py#L34 This won't change the **kwargs behavior of the camelCase in pymongo `MongoClient` because pymongo has a caseInsentive method. https://github.com/mongodb/mongo-python-driver/blob/3.12.3/pymongo/mongo_client.py#L651 ``it's OK to pass `authsource` instead of authSource as a keyword argument.`` --- ...20230526_151849_johan.castiblanco_update_authsource_mongo.md | 1 + tutor/templates/apps/openedx/settings/partials/common_all.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20230526_151849_johan.castiblanco_update_authsource_mongo.md diff --git a/changelog.d/20230526_151849_johan.castiblanco_update_authsource_mongo.md b/changelog.d/20230526_151849_johan.castiblanco_update_authsource_mongo.md new file mode 100644 index 0000000..c058004 --- /dev/null +++ b/changelog.d/20230526_151849_johan.castiblanco_update_authsource_mongo.md @@ -0,0 +1 @@ +- [Bugfix] Change `authSource` to `authsource`(LOWERCASE) in mongo db parameters. This allow to authenticate with credentials in openedx code.(by @johanv26) diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index 222fe9e..c7a4669 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -13,7 +13,7 @@ mongodb_parameters = { "password": {% if MONGODB_PASSWORD %}"{{ MONGODB_PASSWORD }}"{% else %}None{% endif %}, # Connection/Authentication "ssl": {{ MONGODB_USE_SSL }}, - "authSource": "{{ MONGODB_AUTH_SOURCE }}", + "authsource": "{{ MONGODB_AUTH_SOURCE }}", "replicaSet": {% if MONGODB_REPLICA_SET %}"{{ MONGODB_REPLICA_SET }}"{% else %}None{% endif %}, {% if MONGODB_AUTH_MECHANISM %}"authMechanism": "{{ MONGODB_AUTH_MECHANISM }}",{% endif %} }