Skip to content

Commit 4805bb6

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 178558d commit 4805bb6

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ libpqrcv_connect(const char *conninfo, bool replication, bool logical,
148148
/* BEGIN_NEON */
149149
const char *keys[7];
150150
const char *vals[7];
151-
char * neon_auth_token = NULL;
152151
/* END_NEON */
153152
int i = 0;
154153

@@ -210,16 +209,14 @@ libpqrcv_connect(const char *conninfo, bool replication, bool logical,
210209
/* BEGIN_NEON */
211210
if (pg_strcasecmp(appname, "walreceiver") == 0)
212211
{
213-
neon_auth_token = getenv("NEON_AUTH_TOKEN");
214-
if (neon_auth_token != NULL)
212+
if (neon_storage_auth_token[0] != '\0')
215213
{
216-
elog(LOG, "Use NEON_AUTH_TOKEN to connect");
217214
keys[++i] = "password";
218-
vals[i] = neon_auth_token;
215+
vals[i] = neon_storage_auth_token;
219216
}
220217
else
221218
{
222-
elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment");
219+
elog(LOG, "no storage authentication token set");
223220
}
224221
}
225222
/* END_NEON */

src/backend/replication/walreceiver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
int wal_receiver_status_interval;
8888
int wal_receiver_timeout;
8989
bool hot_standby_feedback;
90+
char *neon_storage_auth_token;
9091

9192
/* libpqwalreceiver connection */
9293
static WalReceiverConn *wrconn = NULL;

src/backend/utils/misc/guc_tables.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "replication/slot.h"
7272
#include "replication/slotsync.h"
7373
#include "replication/syncrep.h"
74+
#include "replication/walreceiver.h"
7475
#include "storage/bufmgr.h"
7576
#include "storage/large_object.h"
7677
#include "storage/pg_shmem.h"
@@ -4799,6 +4800,17 @@ struct config_string ConfigureNamesString[] =
47994800
check_restrict_nonsystem_relation_kind, assign_restrict_nonsystem_relation_kind, NULL
48004801
},
48014802

4803+
{
4804+
{"neon_storage_auth_token", PGC_SU_BACKEND, 0,
4805+
"Authentication token for Neon storage",
4806+
NULL,
4807+
GUC_SUPERUSER_ONLY
4808+
},
4809+
&neon_storage_auth_token,
4810+
"",
4811+
NULL, NULL, NULL
4812+
},
4813+
48024814
/* End-of-list marker */
48034815
{
48044816
{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
@@ -29,6 +29,7 @@
2929
extern PGDLLIMPORT int wal_receiver_status_interval;
3030
extern PGDLLIMPORT int wal_receiver_timeout;
3131
extern PGDLLIMPORT bool hot_standby_feedback;
32+
extern PGDLLIMPORT char *neon_storage_auth_token;
3233

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

0 commit comments

Comments
 (0)