-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
🚨 Add ability to enforce SSL in MongoDB source connector #17590
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c883bcb
Check and test for if we are disabling SSL/TLS in source-mongodb-stri…
akashkulk da179fe
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 8e43f75
Update docs
akashkulk 19e4fb0
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 333b4e9
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk ea6e3ca
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 57874e6
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 302fc7c
Address comments
akashkulk 3f718d0
Merge remote-tracking branch 'origin/akashkulkar/mongo-ssl' into akas…
akashkulk ce2c357
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk a2052e9
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk c5803eb
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 209f1d5
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk b9dd838
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 5868e29
Merge branch 'master' into akashkulkar/mongo-ssl
akashkulk 2db1d2f
auto-bump connector version [ci skip]
octavia-squidington-iii e567818
Merge branch 'akashkulkar/mongo-ssl' of https://github.com/airbytehq/…
octavia-squidington-iii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
43 changes: 43 additions & 0 deletions
43
...e-mongodb-v2/src/main/java/io.airbyte.integrations.source.mongodb/MongoDbSourceUtils.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.airbyte.integrations.source.mongodb; | ||
|
||
import static org.bson.BsonType.DATE_TIME; | ||
import static org.bson.BsonType.DECIMAL128; | ||
import static org.bson.BsonType.DOCUMENT; | ||
import static org.bson.BsonType.DOUBLE; | ||
import static org.bson.BsonType.INT32; | ||
import static org.bson.BsonType.INT64; | ||
import static org.bson.BsonType.OBJECT_ID; | ||
import static org.bson.BsonType.STRING; | ||
import static org.bson.BsonType.TIMESTAMP; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.db.jdbc.JdbcUtils; | ||
import java.util.Set; | ||
import org.bson.BsonType; | ||
|
||
public final class MongoDbSourceUtils { | ||
|
||
private MongoDbSourceUtils() {} | ||
|
||
public static final String MONGODB_SERVER_URL = "mongodb://%s%s:%s/%s?authSource=%s&ssl=%s"; | ||
public static final String MONGODB_CLUSTER_URL = "mongodb+srv://%s%s/%s?authSource=%s&retryWrites=true&w=majority&tls=true"; | ||
public static final String MONGODB_REPLICA_URL = "mongodb://%s%s/%s?authSource=%s&directConnection=false&ssl=true"; | ||
public static final String USER = "user"; | ||
public static final String INSTANCE_TYPE = "instance_type"; | ||
public static final String INSTANCE = "instance"; | ||
public static final String CLUSTER_URL = "cluster_url"; | ||
public static final String SERVER_ADDRESSES = "server_addresses"; | ||
public static final String REPLICA_SET = "replica_set"; | ||
public static final String AUTH_SOURCE = "auth_source"; | ||
public static final String PRIMARY_KEY = "_id"; | ||
public static final Set<BsonType> ALLOWED_CURSOR_TYPES = Set.of(DOUBLE, STRING, DOCUMENT, OBJECT_ID, DATE_TIME, | ||
INT32, TIMESTAMP, INT64, DECIMAL128); | ||
|
||
/** | ||
* Determines whether TLS/SSL should be enabled for a standalone instance of MongoDB. | ||
*/ | ||
public static boolean tlsEnabledForStandaloneInstance(final JsonNode config, final JsonNode instanceConfig) { | ||
return config.has(JdbcUtils.TLS_KEY) ? config.get(JdbcUtils.TLS_KEY).asBoolean() | ||
: (instanceConfig.has(JdbcUtils.TLS_KEY) ? instanceConfig.get(JdbcUtils.TLS_KEY).asBoolean() : true); | ||
} | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should both the javadoc comment and the method name be more generalized? It seems you're passing in an
instanceConfig
so it appears this can be extended in the future to handle otherinstance
types yet this method is specifically for Standalone instances, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually specifically for Standalone instances actually. For Atlas and replica set deployments, we are overrwriting the arguments to always have tls/ssl=true in the parames (see
MONGODB_SERVER_URL
andMONGODB_CLUSTER_URL
above. I was essentially duplicating the logic in the source-mongodb-strict-encrypt's check() method, so pulled it out here. The naming is specifically a warning to not rely on this method for non-standalone instances