mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor(rds): split PostgresProtocolHandler into authenticate and bridge primitives (#2913)
Extract handleAuth into authenticate(...), which returns the post-startup client Socket (or null when the handshake ended early), and a public bridge(...) that relays. RdsAuthProxy and RedshiftAuthProxy now call authenticate then bridge in sequence; RDS and Redshift relay behaviour is unchanged. This lets a later change replace the Redshift relay with an intercepting bridge without touching the handshake.
This commit is contained in:
1 parent
660e7613bf
commit
5b3c0e01e3
4 files changed
+51
-27
No files matched your search
+24
-6
@@ -81,11 +81,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), testTlsCertificates(),
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -135,11 +138,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), testTlsCertificates(),
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -189,11 +195,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), testTlsCertificates(),
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -252,11 +261,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), tlsCertificates,
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -302,11 +314,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), tlsCertificates,
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
// Client aborts the handshake below — the handler observing that is expected.
|
||||
}
|
||||
@@ -348,11 +363,14 @@ class PostgresProtocolHandlerTest {
|
||||
|
||||
Thread authThread = Thread.ofVirtual().start(() -> {
|
||||
try {
|
||||
PostgresProtocolHandler.handleAuth(
|
||||
Socket activeClient = PostgresProtocolHandler.authenticate(
|
||||
proxyClient, backend,
|
||||
"dbadmin", "adminpass", "postgres",
|
||||
false, testSigV4Validator(), testTlsCertificates(),
|
||||
(user, pass) -> true);
|
||||
if (activeClient != null) {
|
||||
PostgresProtocolHandler.bridge(activeClient, backend);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user