-
-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDB auth related issue in MONGO_URI #1478
Comments
hi @smeng9 I'll be happy to review your PR |
The same thing happens here when MONGO_DBNAME is different from what is specified in the URI via authSource=. The auth source from the URI gets overwritten by MONGO_DBNAME. Workaround is to not use MONGO_URI at all but use MONGO_HOST, MONGO_PORT & MONGO_AUTH_SOURCE with MONGO_USERNAME and MONGO_PASSWORD together with MONGO_DBNAME |
Hello All, I'm using Atlas free and it requires Thanks! |
I've ran into this issue today when learning Eve. Eve changes URI below works without problems when using pymongo:
But Eve changes it under the hood to:
Edit: I've made some changes to make this comment look less offensive. Sorry guys for my bad attitude yesterday. I really appreciate this project and your hard work. |
Hi,
I don’t think this is at all possible without using the URI method and in
your case will require a fix in the current code.
Honestly I don’t understand why, if one is using the URI method, the code
is trying to read info from the variables other than DBNAME, which is the
only one that cannot be provided via the URI. I.e. if someone wants / needs
to use the URI method then require them to specify all the options via the
URI, apart from the DBNAME. This has always been confusing me from day one.
Otherwise just let the code only read the MONGO_* settings if they are
absent in the URI and only then expand the connection info kwargs with
these settings.
This will not be backwards compatible but then again so isn’t the current
state of 2.x.
With kind regards,
Michel
Op vr 2 sep. 2022 om 22:18 schreef rafrafek ***@***.***>
… How can I stop using URI when using Atlas free? I need srv in my URI,
where should I put "srv" without URI?
—
Reply to this email directly, view it on GitHub
<#1478 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF5I3ILV4E2T4YQQJU6MVWLV4JOKPANCNFSM53M5LJ3Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I have an idea that maybe we could inject MongoClient instance into Eve. In that way we can move responsibility of handling mongodb connection from Eve to pymongo. It would fix this issue and perhaps prevent other connection issues in the future. It could be used in from pymongo import MongoClient
MONGO_CLIENT = MongoClient("mongodb+srv://...") |
Hi all, I just merged #1482. Can you please check current master and confirm if it fixes the problem for you? |
Hello Nicola, Yes, it fixes the issue immediately. Now I can specify It looks like this old issue is resolved. Thanks! Can somebody paste link to this solution here in discussion from 2018: https://groups.google.com/g/python-eve/c/9eJjCSy7wy0 ? |
FWIW,
1.1.5 should not display this issue so maybe resorting to this version is
an option for you rafrafek?
Regards,
Michel
I wasted couple of hours today trying to learn Eve, I don't understand why
… Eve changes authSource from default admin to eve. I had to run debugger
and check step-by-step what is the difference between connecting with bare
pymongo and connecting with Eve. There is only one difference: source set
to eve. I don't even know how it is being set. There is no place in my
code where eve could be typed. There is no authSource="eve" in Eve
sources. Why Eve changes connection parameters so it cannot authenticate
and there is no documentation that even setting authSource in URI does not
work.
It works perfectly when using pymongo:
***@***.***/?retryWrites=true&w=majority&authMechanism=DEFAULT&authSource=admin
But Eve magically changes it under the hood to:
***@***.***/?retryWrites=true&w=majority&authMechanism=DEFAULT&authSource=eve
—
Reply to this email directly, view it on GitHub
<#1478 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF5I3INFV2VOE27VE3YL43TV4JPPZANCNFSM53M5LJ3Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Actual Behavior
MONGO_URI's username, password, and authSource in uri are not parsed correctly
It uses dbname as authSource, but the authSource should be parsed from options https://pymongo.readthedocs.io/en/stable/api/pymongo/uri_parser.html#pymongo.uri_parser.parse_uri
See URI format https://www.mongodb.com/docs/manual/reference/connection-string/
Environment
I am willing to open a PR to resolve the issue. Thanks
The text was updated successfully, but these errors were encountered: