mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(rds): apply IAM auth toggles to running proxies (#3668)
Signed-off-by: 7487 <1042653432@qq.com>
This commit is contained in:
1 parent
2ee3aa67c0
commit
e1e98fd8dc
5 files changed
+43
-9
No files matched your search
@@ -1523,6 +1523,8 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
}
|
||||
instance.setMasterPassword(newPassword);
|
||||
}
|
||||
boolean iamChanged = iamEnabled != null
|
||||
&& iamEnabled != instance.isIamDatabaseAuthenticationEnabled();
|
||||
if (iamEnabled != null) {
|
||||
instance.setIamDatabaseAuthenticationEnabled(iamEnabled);
|
||||
}
|
||||
@@ -1549,6 +1551,10 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
proxyManager.updateMasterPassword(
|
||||
rdsResourceRelayKey(instance.getDbInstanceArn(), id), instance.getMasterPassword());
|
||||
}
|
||||
if (iamChanged) {
|
||||
proxyManager.updateIamEnabled(
|
||||
rdsResourceRelayKey(instance.getDbInstanceArn(), id), iamEnabled);
|
||||
}
|
||||
|
||||
LOG.infov("DB instance {0} modified", id);
|
||||
return instance;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RdsAuthProxy {
|
||||
private static final Logger LOG = Logger.getLogger(RdsAuthProxy.class);
|
||||
|
||||
private final int backendPort;
|
||||
private final boolean iamEnabled;
|
||||
private volatile boolean iamEnabled;
|
||||
private final String instanceId;
|
||||
private final String backendHost;
|
||||
private final String masterUsername;
|
||||
@@ -74,6 +74,11 @@ public class RdsAuthProxy {
|
||||
this.masterPassword = newPassword;
|
||||
}
|
||||
|
||||
/** Apply an IAM-auth setting change to new connections without restarting the listener. */
|
||||
public void updateIamEnabled(boolean enabled) {
|
||||
this.iamEnabled = enabled;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
running = false;
|
||||
try {
|
||||
|
||||
@@ -88,6 +88,14 @@ public class RdsProxyManager {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateIamEnabled(String instanceId, boolean enabled) {
|
||||
RdsAuthProxy proxy = proxies.get(instanceId);
|
||||
if (proxy != null) {
|
||||
proxy.updateIamEnabled(enabled);
|
||||
LOG.infov("Updated RDS proxy IAM authentication for instance {0}", instanceId);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopProxy(String instanceId) {
|
||||
RdsAuthProxy proxy = proxies.get(instanceId);
|
||||
if (proxy != null) {
|
||||
|
||||
Reference in new issue
Block a user