Adding authSource to mongodb auth

This commit is contained in:
Samuel Clay 2021-07-12 21:53:09 -04:00
parent 0d266d7569
commit 4dd3bafbfb
5 changed files with 6 additions and 4 deletions

View file

@ -8,6 +8,8 @@ create_user: nb
local_key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
copy_local_key: "{{ lookup('file', '/srv/secrets-newsblur/keys/docker.key.pub') }}"
mongodb_keyfile: "{{ lookup('file', '/srv/secrets-newsblur/keys/mongodb_keyfile.key') }}"
mongodb_username: "{{ lookup('ini', 'mongodb_username section=nbauth file=/srv/secrets-newsblur/configs/mongodb_auth.ini') }}"
mongodb_password: "{{ lookup('ini', 'mongodb_password section=nbauth file=/srv/secrets-newsblur/configs/mongodb_auth.ini') }}"
sys_packages: [
'git',
'python3',

View file

@ -16,7 +16,7 @@
networks:
- name: newsblurnet
env:
MONGODB_URI: 'mongodb://nb:KCi@db-mongo.service.nyc1.consul:27017/admin?'
MONGODB_URI: 'mongodb://{{ mongodb_username }}:{{ mongodb_password }}@db-mongo.service.nyc1.consul:27017/admin?authSource=nbauth'
ports:
- '9216:9216'

View file

@ -28,8 +28,8 @@ processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
keyFile: /srv/newsblur/config/mongodb_keyfile.key
# authorization: enabled # No RBAC
operationProfiling:
mode: slowOp

View file

@ -67,7 +67,7 @@ def db_check_mysql():
@app.route("/db_check/mongo")
def db_check_mongo():
try:
client = pymongo.MongoClient(f'mongodb://{settings.MONGO_DB['username']}:{settings.MONGO_DB['password']}@db-mongo.server.nyc1.consul')
client = pymongo.MongoClient(f'mongodb://{settings.MONGO_DB['username']}:{settings.MONGO_DB['password']}@db-mongo.server.nyc1.consul?authSource=nbauth')
db = client.newsblur
except:
abort(503)

View file

@ -20,7 +20,7 @@ def main():
r = redis.Redis(connection_pool=settings.REDIS_ANALYTICS_POOL)
try:
client = pymongo.MongoClient(f'mongodb://{settings.MONGO_DB['username']}:{settings.MONGO_DB['password']}@{settings.MONGO_DB['host']}')
client = pymongo.MongoClient(f'mongodb://{settings.MONGO_DB['username']}:{settings.MONGO_DB['password']}@{settings.MONGO_DB['host']}?authSource=nbauth')
feeds_fetched = client.newsblur.statistics.find_one({"key": "feeds_fetched"})['value']
redis_task_fetches = int(r.get(monitor_key) or 0)
except Exception as e: