Skip to content

Fix MongoDB 8.x auth problem - #273

Merged
comtihon merged 4 commits into
comtihon:masterfrom
haoxianhan:fix/mongo8-auth-preflight
Mar 13, 2026
Merged

Fix MongoDB 8.x auth problem#273
comtihon merged 4 commits into
comtihon:masterfrom
haoxianhan:fix/mongo8-auth-preflight

Conversation

@haoxianhan

@haoxianhan haoxianhan commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix mc_worker_api:connect/1 for MongoDB 8.1+ when pre-auth buildInfo is rejected.

mc_worker_api:connect/1 used buildInfo before auth to detect the server version.
On MongoDB 8.1+, that can fail with Unauthorized, so SCRAM auth never starts.

This change removes that auth-time buildInfo check and uses the handshake response to choose the auth mode instead.
Also adds a regression test and runs it in CI against MongoDB 8.2.5.

Testing

  • rebar3 ct --suite=test/buildinfo_auth_SUITE.erl

@turingmachinerepair

Copy link
Copy Markdown
Contributor

Just want to add that it affects MongoDB 8.1 and newer https://www.mongodb.com/docs/manual/release-notes/8.2-compatibility/#driver-incompatibility
And signal that I am also interested in this fix.

@haoxianhan

Copy link
Copy Markdown
Contributor Author

The branch has been updated since the initial PR version. Instead of only handling the pre-auth buildInfo Unauthorized case, the current change removes the auth-time buildInfo dependency entirely and uses the handshake response
(hello/isMaster + maxWireVersion) to choose the auth path.

There is no official mongo:8.1 tag on Docker Hub right now, so the regression test uses mongo:8.2.5, which matches the MongoDB version currently used in production in my case.

@haoxianhan
haoxianhan force-pushed the fix/mongo8-auth-preflight branch 2 times, most recently from a8e3167 to 5a935ee Compare March 13, 2026 05:46
Use the handshake response to choose the auth path instead of calling buildInfo before authentication.

Keep mc_auth_logic:auth/5 backward compatible, add a regression suite, and run it in CI against MongoDB 8.2.5.
@haoxianhan
haoxianhan force-pushed the fix/mongo8-auth-preflight branch from 5a935ee to 8aa6e43 Compare March 13, 2026 05:51
@comtihon
comtihon merged commit 7103e53 into comtihon:master Mar 13, 2026
14 checks passed
@comtihon

Copy link
Copy Markdown
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants