Skip to content
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

Feature/172 x509 support #364

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

Ahmadre
Copy link
Contributor

@Ahmadre Ahmadre commented Feb 21, 2024

Related Issues

Summary

This PR extends the Authenticator in the driver to authenticate via X.509.

It uses under the hood following connection: https://www.mongodb.com/docs/manual/tutorial/configure-x509-client-authentication/#authenticate-with-a-x-509-certificate

Verifications

  1. Atlas Sharded Cluster created in MongoDB Cloud
  2. Created an X.509 PEM File (password protected) and downloaded the *.pem file.
  3. Loaded *.pem file via Dart (was already supported):
var db = Db('mongodb+srv://mongo-dart.xxxxxxx.mongodb.net/?authSource=\$external&authMechanism=MONGODB-X509&retryWrites=true&w=majority');

await db.open(
  secure: true,
  tlsCertificateKeyFile: tlsFilePath,
  tlsCertificateKeyFilePassword: tlsFilePassword
);

Please keep in mind, that authSource=\$external is just a Dart escaped String for: authSource=$external ! If you setup your MongoDB URI via Environment variables keep in mind that the official Mongo setting for the AuthDB is: $external!

  1. Test on Windows Desktop (example.dart):
Launching lib\main.dart on Windows in debug mode...
package:mongo_dart_web/main.dart:1
√  Built build\windows\x64\runner\Debug\web.exe.
Connecting to VM Service at ws://127.0.0.1:54980/X3MBcL2N9iY=/ws
flutter: ====================================================================
flutter: >> Adding Authors
flutter: {_id: ObjectId("65d5648f476690c4e2000000"), name: William Shakespeare, email: william@shakespeare.com, age: 587}
flutter: {_id: ObjectId("65d5648f476691c4e2000000"), name: Jorge Luis Borges, email: jorge@borges.com, age: 123}
flutter: ====================================================================
flutter: >> Authors ordered by age ascending
flutter: [Jorge Luis Borges]:[jorge@borges.com]:[123]
flutter: [William Shakespeare]:[william@shakespeare.com]:[587]
flutter: ====================================================================
flutter: >> Adding Users
flutter: {_id: ObjectId("65d5648f476692c4e2000000"), login: jdoe, name: John Doe, email: john@doe.com}
flutter: {_id: ObjectId("65d5648f476693c4e2000000"), login: lsmith, name: Lucy Smith, email: lucy@smith.com}
flutter: ====================================================================
flutter: >> Users ordered by login descending
flutter: [lsmith]:[Lucy Smith]:[lucy@smith.com]
flutter: [jdoe]:[John Doe]:[john@doe.com]
flutter: ====================================================================
flutter: >> Adding articles
flutter: ====================================================================
flutter: >> Articles ordered by title ascending
flutter: [Caminando por Buenos Aires]:[Las callecitas de Buenos Aires tienen ese no se que...]:[65d5648f476691c4e2000000]
flutter: [I must have seen thy face before]:[Thine eyes call me in a new way]:[65d5648f476690c4e2000000]
Reloaded 98 of 1661 libraries in 392ms (compile: 144 ms, reload: 102 ms, reassemble: 65 ms).
Application finished.
image

@Ahmadre
Copy link
Contributor Author

Ahmadre commented Feb 21, 2024

@giorgiofran

@giorgiofran giorgiofran merged commit 423fbe1 into mongo-dart:main Feb 21, 2024
@giorgiofran
Copy link
Contributor

Thanks Ahmadre

@Ahmadre
Copy link
Contributor Author

Ahmadre commented Feb 21, 2024

Thanks Ahmadre

Thank you too :)

@Ahmadre Ahmadre deleted the feature/172_x509-support branch February 21, 2024 22:53
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.

2 participants