Skip to content

Commit e470d7d

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 <tristan.partin@databricks.com>
1 parent b7509d4 commit e470d7d

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
@@ -131,7 +131,6 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
131131
/* BEGIN_NEON */
132132
const char *keys[7];
133133
const char *vals[7];
134-
char * neon_auth_token = NULL;
135134
/* END_NEON */
136135
int i = 0;
137136

@@ -145,16 +144,14 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
145144
/* BEGIN_NEON */
146145
if (pg_strcasecmp(appname, "walreceiver") == 0)
147146
{
148-
neon_auth_token = getenv("NEON_AUTH_TOKEN");
149-
if (neon_auth_token != NULL)
147+
if (neon_storage_token[0] != '\0')
150148
{
151-
elog(LOG, "Use NEON_AUTH_TOKEN to connect");
152149
keys[++i] = "password";
153-
vals[i] = neon_auth_token;
150+
vals[i] = neon_storage_token;
154151
}
155152
else
156153
{
157-
elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment");
154+
elog(LOG, "no storage authentication token set");
158155
}
159156
}
160157
/* END_NEON */

src/backend/replication/walreceiver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
int wal_receiver_status_interval;
9191
int wal_receiver_timeout;
9292
bool hot_standby_feedback;
93+
char *neon_storage_token;
9394

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

src/backend/utils/misc/guc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,6 +4801,17 @@ static struct config_string ConfigureNamesString[] =
48014801
check_restrict_nonsystem_relation_kind, assign_restrict_nonsystem_relation_kind, NULL
48024802
},
48034803

4804+
{
4805+
{"neon_storage_token", PGC_POSTMASTER, REPLICATION_STANDBY,
4806+
"Authentication token for Neon storage",
4807+
NULL,
4808+
GUC_SUPERUSER_ONLY
4809+
},
4810+
&neon_storage_token,
4811+
"",
4812+
NULL, NULL, NULL
4813+
},
4814+
48044815
/* End-of-list marker */
48054816
{
48064817
{NULL, 0, 0, NULL, NULL}, NULL, 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 PGDLLIMPORT int wal_receiver_status_interval;
2929
extern PGDLLIMPORT int wal_receiver_timeout;
3030
extern PGDLLIMPORT bool hot_standby_feedback;
31+
extern PGDLLIMPORT char *neon_storage_token;
3132

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

0 commit comments

Comments
 (0)