aws / aws/aws-secretsmanager-jdbc
Connection proprties are not passed to underlying driver by AWSSecretsManagerDriver
- Dominant language
- Java
- Stars
- 196
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
in **AWSSecretsManagerDriver** properties that are supposed to be passed to wrapped's driver connect(url, properties); are missing. the issue is in
**Properties updatedInfo = new Properties(info);** (see code snippet below)
This creates hierarchical (nested) properties that must be iterated using `Properties.stringPropertyNames()` but I would say most of the drivers **including Microsoft SQL Server** won't do it they'll use inherited Map methods and will miss all the originally configured (nested) properties
I suspect it was not AWSSecretsManagerDriver developers intention to create nested properties but to create a copy of properties and then set password and overwrite user. but that is not what **new Properties(info);** does
we would greatly appreciate if it could be fixed ASAP - we need to pass some extra properties to MS SQL driver
```java
private Connection connectWithSecret(String unwrappedUrl, Properties info, String credentialsSecretId)
throws SQLException, InterruptedException {
int retryCount = 0;
while (retryCount++ <= MAX_RETRY) {
String secretString = secretCache.getSecretString(credentialsSecretId);
Properties updatedInfo = new Properties(info);
try {
JsonNode jsonObject = mapper.readTree(secretString);
updatedInfo.setProperty("user", jsonObject.get("username").asText());
updatedInfo.setProperty("password", jsonObject.get("password").asText());
} catch (IOException e) {
// Most likely to occur in the event that the data is not JSON.
// Or the secret's username and/or password fields have been
// removed entirely. Either scenario is most often a user error.
throw new RuntimeException(INVALID_SECRET_STRING_JSON);
}
try {
return getWrappedDriver().connect(unwrappedUrl, updatedInfo);
} catch (Exception e) {
if (isExceptionDueToAuthenticationError(e)) {
boolean refreshSuccess = this.secretCache.refreshNow(credentialsSecretId);
if (!refreshSuccess) {
throw(e);
}
}
else {
throw(e);
}
}
}
// Max retries reached
throw new SQLException("Connect failed to authenticate: reached max connection retries");
}
```
**To Reproduce**
Steps to reproduce the behavior:
**Expected behavior**
A description of what you expected to happen.
**Environment:**
Details about your environment (OS, Java version, AWS SDK version...)
**Additional context**
Add any other context about the problem here.
Contributor guide
Research direction
Start in AWSSecretsManagerDriver.connectWithSecret, focusing on how Properties updatedInfo is created before getWrappedDriver().connect is called. Verify that the originally supplied connection properties, along with the secret username and password, reach the wrapped driver; add or run a focused connection test using an extra driver property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100