Skip to content

Commit

Permalink
Actual Fix for the connector
Browse files Browse the repository at this point in the history
We have to quote the Username and password. From the documentation of pymongo

For username and
        passwords reserved characters like ':', '/', '+' and '@' must be
        percent encoded following RFC 2396::
  • Loading branch information
Vagoasdf committed Jan 20, 2025
1 parent b8e940c commit db7b3fa
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/fides/api/service/connectors/mongodb_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from loguru import logger
from pymongo import MongoClient
from pymongo.errors import OperationFailure, ServerSelectionTimeoutError
import urllib
from urllib.parse import quote_plus

from fides.api.common_exceptions import ConnectionException
from fides.api.graph.execution import ExecutionNode
Expand Down Expand Up @@ -35,14 +35,12 @@ def build_uri(self) -> str:
user_pass: str = ""
default_auth_db: str = ""
if config.username and config.password:
user_pass = urllib.parse.quote_plus( f"{config.username}:{config.password}@")

user_pass = ( f"{quote_plus(config.username)}:{quote_plus(config.password)}@")
if config.defaultauthdb:
default_auth_db = f"/{config.defaultauthdb}"

port: str = f":{config.port}" if config.port else ""
url = f"mongodb://{user_pass}{config.host}{port}{default_auth_db}"
logger.info("Built URI: {}", url)
return url

def create_client(self) -> MongoClient:
Expand Down

0 comments on commit db7b3fa

Please sign in to comment.