You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow registering custom CredentialProviders for per-conn passwords
When using a temporary credential system for MySQL, for example IAM
database authenticaiton on AWS or the Database secret backend for
Hashicorp Vault, it may not be the case that the same username and
password be used for opening every connection in a *sql.DB.
This PR adds funcionality whereby the caller can, instead of specifying
cfg.User and cfg.Passwd (in the DSN as user:pass@...), specify a
CredentialProvider= arguemnt which refers to a callback registered with
RegisterCredentialProvider.
When a new connection is to be opened, if the CredentialProvider
callback is specified, that is called to obtain a username/password pair
rather than using the values from the DSN.
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -209,6 +209,16 @@ SELECT u.id FROM users as u
209
209
210
210
will return `u.id` instead of just `id` if `columnsWithAlias=true`.
211
211
212
+
#### `credentialProvider`
213
+
214
+
```
215
+
Type: string
216
+
Valid Values: <name>
217
+
Default: ""
218
+
```
219
+
220
+
If set, this must refer to a credential provider name registerd with `RegisterCredentialProvider`. When this is set, the username and password in the DSN will be ignored; instead, each time a conneciton is to be opened, the named credential provider function will be called to obtain a username/password to connect with. This is useful when using, for example, IAM database auth in Amazon AWS, where "passwords" are actually temporary tokens that expire.
0 commit comments