Skip to content

Commit

Permalink
base fix for the connector, use urllib
Browse files Browse the repository at this point in the history
We would be able to parse the special url chars
  • Loading branch information
Vagoasdf committed Jan 17, 2025
1 parent fdd8b4b commit b8e940c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fides/api/service/connectors/mongodb_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from loguru import logger
from pymongo import MongoClient
from pymongo.errors import OperationFailure, ServerSelectionTimeoutError
import urllib

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

Please sign in to comment.