Skip to content

Commit ae90805

Browse files
committed
Move NEON_AUTH_TOKEN to a builtin GUC
This environment variable is used as the password to connect to another postgres instance as the walreceiver. The purpose of moving to a GUC is so that we can reload the storage auth token periodically. Signed-off-by: Tristan Partin <[email protected]>
1 parent 05f5c08 commit ae90805

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
130130
/* BEGIN_NEON */
131131
const char *keys[7];
132132
const char *vals[7];
133-
char * neon_auth_token = NULL;
134133
/* END_NEON */
135134
int i = 0;
136135

@@ -144,16 +143,14 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
144143
/* BEGIN_NEON */
145144
if (pg_strcasecmp(appname, "walreceiver") == 0)
146145
{
147-
neon_auth_token = getenv("NEON_AUTH_TOKEN");
148-
if (neon_auth_token != NULL)
146+
if (neon_storage_auth_token[0] != '\0')
149147
{
150-
elog(LOG, "Use NEON_AUTH_TOKEN to connect");
151148
keys[++i] = "password";
152-
vals[i] = neon_auth_token;
149+
vals[i] = neon_storage_auth_token;
153150
}
154151
else
155152
{
156-
elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment");
153+
elog(LOG, "no storage authentication token set");
157154
}
158155
}
159156
/* END_NEON */

src/backend/replication/walreceiver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
int wal_receiver_status_interval;
9090
int wal_receiver_timeout;
9191
bool hot_standby_feedback;
92+
char *neon_storage_auth_token;
9293

9394
/* libpqwalreceiver connection */
9495
static WalReceiverConn *wrconn = NULL;

src/backend/utils/misc/guc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5056,6 +5056,17 @@ static struct config_enum ConfigureNamesEnum[] =
50565056
NULL, NULL, NULL
50575057
},
50585058

5059+
{
5060+
{"neon_storage_auth_token", PGC_SU_BACKEND, 0,
5061+
"Authentication token for Neon storage",
5062+
NULL,
5063+
GUC_SUPERUSER_ONLY
5064+
},
5065+
&neon_storage_auth_token,
5066+
"",
5067+
NULL, NULL, NULL
5068+
},
5069+
50595070
/* End-of-list marker */
50605071
{
50615072
{NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL

src/include/replication/walreceiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
extern int wal_receiver_status_interval;
2929
extern int wal_receiver_timeout;
3030
extern bool hot_standby_feedback;
31+
extern PGDLLIMPORT char *neon_storage_auth_token;
3132

3233
/*
3334
* MAXCONNINFO: maximum size of a connection string.

0 commit comments

Comments
 (0)