Skip to content

Commit 3e7c8e2

Browse files
Haoyu Huangtristan957
authored andcommitted
WALRecevier read password from env var (#40)
primary_conninfo string is too long with password. Wal receiver reads the password from NEON_AUTH_TOKEN instead.
1 parent 93feb20 commit 3e7c8e2

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
128128
{
129129
WalReceiverConn *conn;
130130
PostgresPollingStatusType status;
131-
const char *keys[6];
132-
const char *vals[6];
131+
/* BEGIN_NEON */
132+
const char *keys[7];
133+
const char *vals[7];
134+
char * neon_auth_token = NULL;
135+
/* END_NEON */
133136
int i = 0;
134137

135138
/*
@@ -138,6 +141,24 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
138141
*/
139142
keys[i] = "dbname";
140143
vals[i] = conninfo;
144+
145+
/* BEGIN_NEON */
146+
if (pg_strcasecmp(appname, "walreceiver") == 0)
147+
{
148+
neon_auth_token = getenv("NEON_AUTH_TOKEN");
149+
if (neon_auth_token != NULL)
150+
{
151+
elog(LOG, "Use NEON_AUTH_TOKEN to connect");
152+
keys[++i] = "password";
153+
vals[i] = neon_auth_token;
154+
}
155+
else
156+
{
157+
elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment");
158+
}
159+
}
160+
/* END_NEON */
161+
141162
keys[++i] = "replication";
142163
vals[i] = logical ? "database" : "true";
143164
if (!logical)

0 commit comments

Comments
 (0)