Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ interface ConnectionInfoCache {
boolean isClosed();

ConnectionConfig getConfig();

void recordIamPrincipal(String user, String database);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,33 @@ ListenableFuture<ConnectionInfo> getConnectionInfo(
ListeningScheduledExecutorService executor,
ListenableFuture<KeyPair> keyPair);

default ListenableFuture<ConnectionInfo> getConnectionInfo(
CloudSqlInstanceName instanceName,
AccessTokenSupplier accessTokenSupplier,
AuthType authType,
ListeningScheduledExecutorService executor,
ListenableFuture<KeyPair> keyPair,
java.util.List<com.google.cloud.sql.IpType> ipTypes) {
return getConnectionInfo(instanceName, accessTokenSupplier, authType, executor, keyPair);
}

ConnectionInfo getConnectionInfoSync(
CloudSqlInstanceName instanceName,
AccessTokenSupplier accessTokenSupplier,
AuthType authType,
KeyPair keyPair);

default ConnectionInfo getConnectionInfoSync(
CloudSqlInstanceName instanceName,
AccessTokenSupplier accessTokenSupplier,
AuthType authType,
KeyPair keyPair,
java.util.List<com.google.cloud.sql.IpType> ipTypes) {
return getConnectionInfoSync(instanceName, accessTokenSupplier, authType, keyPair);
}

default void recordIamPrincipal(
CloudSqlInstanceName instanceName, String user, String database) {}

String resolveConnectionName(String region, String dnsName);
}
3 changes: 3 additions & 0 deletions core/src/main/java/com/google/cloud/sql/core/Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ private Socket connectDirect(ConnectionConfig config, long timeoutMs) throws IOE
&& !Strings.isNullOrEmpty(config.getMdxClientProtocolType())) {
socket = mdxProtocolHandler.connect(socket, config.getMdxClientProtocolType());
}
if (config.getAuthType() == com.google.cloud.sql.AuthType.IAM) {
socket = new PostgresStartupSnifferSocket(socket, instance::recordIamPrincipal);
}

logger.debug(String.format("[%s] Connected to instance successfully.", successfulIp));
instance.addSocket(socket);
Expand Down
Loading
Loading