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

add uri encoding for mongodb connector password🐛 #31371

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ data:
tags:
- language:java
releases:
1.0.1:
message: >
Patched bug where passwords with special characters were not being handled correctly.
aglucky marked this conversation as resolved.
Show resolved Hide resolved
breakingChanges:
1.0.0:
message: >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package io.airbyte.integrations.source.mongodb;

import java.net.URLEncoder;

import static io.airbyte.integrations.source.mongodb.MongoConstants.DRIVER_NAME;

import com.mongodb.ConnectionString;
Expand Down Expand Up @@ -40,7 +42,7 @@ public static MongoClient createMongoClient(final MongoDbSourceConfig config) {
if (config.hasAuthCredentials()) {
final String authSource = config.getAuthSource();
final String user = config.getUsername();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does user need encoding as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears so. I didn't realize usernames were allowed to have special characters in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like any of the class that generate the client connection string take care of encoding.
great stuff!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just addressed the feedback!

final String password = config.getPassword();
final String password = URLEncoder.encode(config.getPassword(), StandardCharsets.UTF_8);
mongoClientSettingsBuilder.credential(MongoCredential.createCredential(user, authSource, password.toCharArray()));
}

Expand Down
Loading