Add X509 certificate authentication support#268
Open
houst0n wants to merge 1 commit into
Open
Conversation
This commit adds support for MongoDB X509 client certificate authentication:
- Add x509_auth/2,3 functions to mc_auth_logic.erl for X509 authentication
- Update mc_worker_api:connect/1 to support {auth_mechanism, 'MONGODB-X509'}
- Fix mongo_protocol.erl to respect database field from op_msg_command
(required for $external database used by X509 auth)
- Add scripts/setup_mongodb8_x509.sh for setting up MongoDB with X509 auth
- Add x509_auth_SUITE.erl with tests for:
- Successful X509 authentication
- X509 auth with explicit subject
- Rejection of invalid certificates
- Database operations with X509 auth
- Failure when SSL is not enabled
- Update start_mongo_auth.sh to create testuser in admin database
- Update rebar3 for Erlang 28 compatibility
Usage example:
{ok, Conn} = mc_worker_api:connect([
{host, "localhost"},
{port, 27022},
{ssl, true},
{ssl_opts, [
{certfile, "/path/to/client.pem"},
{keyfile, "/path/to/client.key"},
{cacertfile, "/path/to/ca.pem"}
]},
{auth_mechanism, 'MONGODB-X509'}
]).
I'm using this for serveral weeks without issues (OTP28/Mongo7+8)
Open
Owner
|
Hi @houst0n thank you very much for your contribution. |
Owner
|
please fix the checks |
Contributor
|
@houst0n pinging you again to fix the checks and resolve conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds support for MongoDB X509 client certificate authentication:
Usage example:
{ok, Conn} = mc_worker_api:connect([ {host, "localhost"}, {port, 27022}, {ssl, true}, {ssl_opts, [ {certfile, "/path/to/client.pem"}, {keyfile, "/path/to/client.key"}, {cacertfile, "/path/to/ca.pem"} ]}, {auth_mechanism, 'MONGODB-X509'} ]).
I'm using this for serveral weeks without issues (OTP28/Mongo7+8)