Skip to content

mongodb backend accept authsource option#4581

Closed
jinuljt wants to merge 1 commit into
celery:masterfrom
jinuljt:master
Closed

mongodb backend accept authsource option#4581
jinuljt wants to merge 1 commit into
celery:masterfrom
jinuljt:master

Conversation

@jinuljt

@jinuljt jinuljt commented Mar 9, 2018

Copy link
Copy Markdown

Description

mongodb backend accept authSource option, separate authenticate database and default database.

And it Fixes #4454

@auvipy auvipy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need tests

@georgepsarakis

Copy link
Copy Markdown
Contributor

@jinuljt are the changes compatible with the MongoDB client version?
Also you can add a very simple test case, probably here:

  • Settings
  • Verify that source parameter is passed correctly to authenticate. You can probably find an example test case here.

@duncaneddy

Copy link
Copy Markdown
Contributor

What left to do to get this PR accepted? I've run into this issue at work and we've tested to confirm the fix here solves the issue.

It looks like the unit tests for this failed because they weren't updated to be compatible with the new format of the function call.

@auvipy

auvipy commented May 15, 2019

Copy link
Copy Markdown
Member

please add unittests

@bwanglzu

Copy link
Copy Markdown

Is there any workaruond before this PR being merged? It has been 1 year ..

@duncaneddy

Copy link
Copy Markdown
Contributor

Unfortunately there are only two workaround options I can see until this is patched:

  1. Monkey-patch the mongodb celery backend to update the function call
  2. Store your data in the admin database used for authentication in mongodb.

Neither of these solutions is really ideal....

I opened a new PR to address this with the requested unittests here: #5527. The tests themselves pass but the current build is failing.

@bwanglzu

bwanglzu commented May 17, 2019

Copy link
Copy Markdown

@duncaneddy Thanks for your reply!

I forked celery and created a release myself using your PR, then replaced celery with git+https://github.com/bwanglzu/celery@mongoauth#egg=celery in requirements.txt, through build not passing, it's working nicely for my celery project.

This is how I confg celery connection string:

from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

# MONGODB CONFIGURATIONS
base_url = None
if not os.environ.get('mongo.user') or not os.environ.get('mongo.password'):
    base_url = 'mongodb://' + os.environ.get('mongo.host') + ':' + os.environ.get('mongo.port')
else:
    base_url = "mongodb://" + os.environ.get('mongo.user') + ':' + os.environ.get('mongo.password') + '@' + \
        os.environ.get('mongo.host') + ':' + os.environ.get('mongo.port')
broker_url = base_url + '/' + os.environ.get('mongo.database') + '?authSource=' + os.environ.get('mongo.auth_source')
result_backend = base_url
mongodb_backend_settings = {
    'database': os.environ.get('mongo.database'),
    'taskmeta_collection': os.environ.get('mongo.collection'),
    'options': {'authSource': os.environ.get('mongo.auth_source')}
}

@thedrow

thedrow commented May 20, 2019

Copy link
Copy Markdown
Contributor

This PR has been superseded by #5527.
Thank you for your contribution. I'll make sure to mention you in the changelog.

@thedrow thedrow closed this May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Celery does not consider authSource on mongodb backend URLs

6 participants