-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 parameter to disable escaping the username and password for database connections #13414
Conversation
Thanks for this submission! Can you please add a changelog entry? I'll get a reviewer for you as soon as I can. Thanks! |
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.
Nice job, @robmonte! Have a few questions/suggestions around where the configuration parameter should live. +1 @hsimon-hashicorp on changelog entry needed. Would also be nice to add some level of test coverage for this.
I was able to successfully test this using an ADO style connection string and MSSQL. One observation about the ADO style connection string is that we no longer warn for a password in connection_url
or redact when reading the config. This is only true is the username/password is supplied directly in the connection_url
, but I thought it'd be worth mentioning.
968c977
to
af5a356
Compare
af5a356
to
c61be0e
Compare
Still working on updating sql_test.go |
c61be0e
to
a91bb3d
Compare
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.
One small note, otherwise looks good!
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.
LGTM!
…word chars for DB connections (hashicorp#13414) * Add a parameter that disables escaping characters in the username or password fields for secrets engines database connections * Always disallow template variables inside the username or password
What problem is this code trying to solve?
I just came across it in the code, and it is unclear to me why this logic was added. |
Hi Max, when working on this feature I kept getting infrequent test failures in between successful runs, like a race condition. At the time, I had narrowed it down to the ConnectionURL sometimes being a different value despite no changes. When building the ConnectionURL, it calls the function At the time I couldn't figure out why this was happening. I started going down this rabbit hole again because of your question here, and I think I figured out the issue this time. To quickly test this, I first commented out the block of code restricting the use of the template values. Next, I used the I was overlooking the fact that this Replacing the username template first (the common case):
...but sometimes, it does the password template first:
The opposite case would also happen from using {{username}} in the password value. At the time, the quickest solution was to simply disallow the use of the template variables as part of the username or password themselves. I also don't see any good coming from allowing the use of them. It just seems like it's asking for trouble. |
Aha! Thanks for the elucidation! I had observed that all template expressions were being replaced in one call to Disallowing the specific template expressions as replacements is a reasonable workaroud - I dislike it because of the potential of surprising someone at some point - it wouldn't be that crazy for |
@robmonte Yes, thanks for the info! I wonder if we should add a comment with a brief reason for this behavior? Specifically might be worth mentioning that it is only required to prevent race conditions in the tests. |
Instead fix the underlying issue of `dbutil.QueryHelper` making multiple passes over the input string, and potentially reprocessing placeholders inserted as a result of previous substitutions. Follow-up to hashicorp#13414
I propose instead we fix the underlying templating routine so the workaround is no longer required: #22224
It would be possible to run into this problem in production too if usernames or passwords contained any sequences like |
This feature adds the ability to disable Vault escaping any special characters in the username and password fields when connecting to a database. When writing the database config, supplying
disable_escaping="true"
will activate this feature. It is off by default/not specified.