Skip to content

Commit e7082c9

Browse files
authored
Merge pull request #11 from llmware-ai/mongo-auth
Support authentication via Mongo connection string
2 parents 4626ef4 + 8f51e30 commit e7082c9

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

docker-compose.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ services:
44
mongodb:
55
container_name: mongodb
66
image: mongo:5.0.10
7-
environment:
8-
# To secure the root account, provide credentials here
9-
MONGO_INITDB_ROOT_USERNAME:
10-
MONGO_INITDB_ROOT_PASSWORD:
7+
# To secure MongoDB, uncomment and set the following values
8+
# environment:
9+
# - MONGO_INITDB_DATABASE=admin
10+
# - MONGO_INITDB_ROOT_USERNAME=admin
11+
# - MONGO_INITDB_ROOT_PASSWORD=changeme
1112
volumes:
1213
- llmware-mongodb:/data/db
1314
ports:

llmware/configs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ class LLMWareConfig:
3535
"prompt_path_name": "prompt_history/",
3636
"tmp_path_name": "tmp/"}
3737

38-
_conf = {"collection_db_uri": "mongodb://localhost:27017/",
39-
"collection_db_username": "",
40-
"collection_db_password": "",
38+
_conf = {"collection_db_uri": os.environ.get("COLLECTION_DB_URI", "mongodb://localhost:27017/"),
39+
"collection_db_username": "", # Not used for now
40+
"collection_db_password": "", # Not used for now
4141
"collection_db": "mongo",
42-
"milvus_host": "localhost",
43-
"milvus_port": 19530,
42+
"milvus_host": os.environ.get("MILVUS_HOST","localhost"),
43+
"milvus_port": int(os.environ.get("MILVUS_PORT",19530)),
4444
"debug_mode": 0,
4545
"llmware_sample_files_bucket": "llmware-sample-docs",
4646
"llmware_public_models_bucket": "llmware-public-models",

llmware/resources.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ class __DBManager:
4949
def __init__(self):
5050

5151
self.collection_db_path = LLMWareConfig.get_config("collection_db_uri")
52-
username = LLMWareConfig.get_config("collection_db_username")
53-
password = LLMWareConfig.get_config("collection_db_password")
5452

5553
# default client is Mongo currently
56-
self.client = MongoClient(self.collection_db_path, username=username, password=password,
57-
unicode_decode_error_handler='ignore')
54+
self.client = MongoClient(self.collection_db_path, unicode_decode_error_handler='ignore')
5855
#self.client.admin.authenticate(username, password)
5956

6057
__instance = None
@@ -70,12 +67,10 @@ def __getattr__(self, item):
7067

7168
def check_db_uri(timeout_secs=5):
7269

73-
username = LLMWareConfig.get_config("collection_db_username")
74-
password = LLMWareConfig.get_config("collection_db_password")
7570
uri_string = LLMWareConfig.get_config("collection_db_uri")
7671

7772
# default client is Mongo currently
78-
client = MongoClient(uri_string, username=username, password=password,unicode_decode_error_handler='ignore')
73+
client = MongoClient(uri_string, unicode_decode_error_handler='ignore')
7974

8075
# self.client.admin.authenticate(username, password)
8176

0 commit comments

Comments
 (0)