-
Notifications
You must be signed in to change notification settings - Fork 1.1k
URL encoding for passwords in MongoDB connection strings #4903
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
Comments
Connection strings are handled fully by the MongoDB driver (see the stack trace using |
If I understand your proposal, you're suggesting to take action on the password outside the application itself (be it on the file or the safe it comes from) and make it URL safe at that point? |
It's either-or:
FWIW, there's also another, more elaborate variant used by e.g. Spring Vault that provides a |
@mp911de, from what we've been testing, ...mongodb.username & ...mongodb.password are being ignored when the uri variant is used: |
Thank you very much for your reply @mp911de I see a bit of inconsistency between the two flavors.
Wouldn't there be a way to do it with the uri? |
Good catch, I entirely missed that Spring Boot backs off from username/password properties when using the connection URL. While that approach for sure had its place in earlier times, now that providing credentials through improved means I think we should revisit that arrangement (see spring-projects/spring-boot#17215 for an earlier discussion). For JDBC, some URL's may contain contain authentication details, however, Boot picks up JDBC username/password properties and routes these accordingly providing much more flexibility and a proper separation between endpoint and authentication concerns. |
Description:
Hello
I am writing to request a feature enhancement related to the handling of passwords in MongoDB connection strings. Currently, when a password contains special characters (in my case, %), it can cause issues when establishing a connection to the database. This is because these characters are not URL-encoded, leading to potential misinterpretation of the connection string.
Use Case:
For example, if a password is p%ssword, the connection string would look like this:
throws the following exception:
To make it work, we would need to manually URL-encode the password. However, our challenge is that we do not have direct access to the password, as it is injected via an environment variable and stored in a secure vault. This means we cannot pre-encode it before it is passed to the application.
Would it be possible to add automatic encoding to the
spring.data.mongodb.uri
property to handle this scenario more seamlessly?Thank you very much
The text was updated successfully, but these errors were encountered: