Skip to content

Commit

Permalink
Merge pull request #29 from EGA-archive/urgent-fix
Browse files Browse the repository at this point in the history
Adding configuration for having TLS on top of mongoDB
  • Loading branch information
costero-e authored Jan 9, 2025
2 parents 6bb8796 + 9794069 commit e127806
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion beacon/conf/api_version.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
api_version: v2.0-eeabc63
api_version: v2.0-6bb8796
7 changes: 2 additions & 5 deletions beacon/connections/mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pymongo.mongo_client import MongoClient
from beacon.connections.mongo import conf
import os

if conf.database_cluster:
uri = "mongodb+srv://{}:{}@{}/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000".format(
Expand All @@ -18,9 +17,7 @@
conf.database_auth_source
)

if os.path.isfile(conf.database_certificate):
uri += '&tls=true&tlsCertificateKeyFile={}'.format(conf.database_certificate)
if os.path.isfile(conf.database_cafile):
uri += '&tlsCAFile={}'.format(conf.database_cafile)
if conf.database_certificate != '' and conf.database_cafile != '':
uri += '&tls=true&tlsCertificateKeyFile={}&tlsCAFile={}'.format(conf.database_certificate, conf.database_cafile)

client = MongoClient(uri)
4 changes: 4 additions & 0 deletions docker-compose.remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ services:
db:
image: mongo:5
command: --wiredTigerCacheSizeGB 4
#command: --wiredTigerCacheSizeGB 4 --sslMode requireSSL --tlsCertificateKeyFile test-server1.pem --tlsCAFile test-ca.pem
hostname: mongo
container_name: mongoprod
ports:
Expand All @@ -71,6 +72,9 @@ services:
- ./beacon/connections/mongo/data/db:/data/db
- ./beacon/connections/mongo/data/configdb:/data/configdb
- ./beacon/connections/mongo/data/caseLevelData:/data/caseLevelData
#- ./test-server1.pem:/test-server1.pem
#- ./test-ca.pem:/test-ca.pem
#- ./test-client.pem:/test-client.pem
#command: --verbose

beacon-ri-tools:
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
db:
image: mongo:5
command: --wiredTigerCacheSizeGB 4
#command: --wiredTigerCacheSizeGB 4 --sslMode requireSSL --tlsCertificateKeyFile test-server1.pem --tlsCAFile test-ca.pem
hostname: mongo
container_name: mongoprod
ports:
Expand All @@ -82,6 +83,9 @@ services:
- ./beacon/connections/mongo/data/db:/data/db
- ./beacon/connections/mongo/data/configdb:/data/configdb
- ./beacon/connections/mongo/data/caseLevelData:/data/caseLevelData
#- ./test-server1.pem:/test-server1.pem
#- ./test-ca.pem:/test-ca.pem
#- ./test-client.pem:/test-client.pem
networks:
- pub
#command: --verbose
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aiohttp-middlewares==2.4.0
aiohttp-jinja2==1.5
aiohttp-session==2.9.0
asyncpg==0.24.0
cryptography==39.0.1
cryptography==41.0.5
PyJWT==2.7.0
python-dotenv==1.0.1
jsonschema==4.21.1
Expand All @@ -17,6 +17,7 @@ loguru==0.7.2
pyyaml==6.0.1
dataclasses-json==0.5.6
pymongo[srv]==4.0.1
pyopenssl==23.3.0
coverage==7.6.0
requests==2.25.1
pydantic==2.6.2
Expand Down

0 comments on commit e127806

Please sign in to comment.