Hi, I'm seeing Authorization Failure trying with M...
# ingestion
f
Hi, I'm seeing Authorization Failure trying with MongoDB using read-only account on non-default database. Note: It works using "super" credentials
Copy code
source:
  type: "mongodb"
  config:
    connect_uri: "<mongodb://my.hostname:27017/mydb>"
    username: "readonly"
    password: "readonly"
    env: "DEV"
    authMechanism: "DEFAULT"
    options:
      tls: True
      tlsCAFile: "/path/to/my.pem"
I suspect the account can't access the "default" database, but putting database on the uri didn't help. Any suggestions?
g
We’re not doing anything fancy in our source - just using the pymongo library under the hood: https://github.com/linkedin/datahub/blob/master/metadata-ingestion/src/datahub/ingestion/source/mongodb.py#L326-L347
Can you try connecting to your mongo instance directly?
f
Hi, Yes it worked with this script:
Copy code
from pymongo import MongoClient
from pprint import pprint
import urllib.parse
username = urllib.parse.quote_plus('readonly')
password = urllib.parse.quote_plus('readonly')
uri = 'mongodb://' + username + ':' + password + '@my.hostname:27017/mydb?tls=true&tlsCAFile=/path/to/my.pem'
client = MongoClient(uri)
db = client.student
pprint(db.my_collection.find_one())
It fails on
database_names: List[str] = client.list_database_names()
. I guess this confirms further privileges are needed...
Granting
readAnyDatabase
role solved the issue. Thanks!
g
Nice
I’ll update the docs here