Skip to content

Celery does not consider authSource on mongodb backend URLs #4454

@thiagogalesi

Description

@thiagogalesi

Version: Celery 4.0.2 (from looking at the changes since then it seems there is no change addressing this issue here: https://github.com/celery/celery/commits/master/celery/backends/mongodb.py )

(Edit) Confirmed with the following versions as well:
amqp==2.2.2
billiard==3.5.0.3
celery==4.1.0
kombu==4.1.0
pymongo==3.6.0

Celery Report

software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:2.7.8
billiard:3.5.0.3 py-amqp:2.2.1
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:amqp results:disabled

Steps to reproduce

Give Celery a Backend URL pointing to a MongoDB instance with authentication and username/password (user/pwd set on the Admin DB by default) in the format:

mongodb://user:pass@your-server/your_db?authSource=admin

(Please see http://api.mongodb.com/python/current/examples/authentication.html#default-database-and-authsource and http://api.mongodb.com/python/current/api/pymongo/mongo_client.html?highlight=authsource )

Expected behavior

Celery authenticates the user in the admin database (this is the same as passing --authenticationDatabase to the mongo client or the same url to MongoClient)

Actual behavior

Celery tries to authenticate the user on the your_db database (failing to authenticate)

Workaround (not recommended)

Change the db on the URL to /admin (this db shouldn't be used to store arbitrary data normally)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions