diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 3f291b4e21f..030ba552c90 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -148,7 +148,6 @@ libpqrcv_connect(const char *conninfo, bool replication, bool logical, /* BEGIN_NEON */ const char *keys[7]; const char *vals[7]; - char * neon_auth_token = NULL; /* END_NEON */ int i = 0; @@ -210,16 +209,14 @@ libpqrcv_connect(const char *conninfo, bool replication, bool logical, /* BEGIN_NEON */ if (pg_strcasecmp(appname, "walreceiver") == 0) { - neon_auth_token = getenv("NEON_AUTH_TOKEN"); - if (neon_auth_token != NULL) + if (neon_storage_auth_token[0] != '\0') { - elog(LOG, "Use NEON_AUTH_TOKEN to connect"); keys[++i] = "password"; - vals[i] = neon_auth_token; + vals[i] = neon_storage_auth_token; } else { - elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment"); + elog(LOG, "no storage authentication token set"); } } /* END_NEON */ diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 6f28fc2e03d..cf790ac5fa6 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -87,6 +87,7 @@ int wal_receiver_status_interval; int wal_receiver_timeout; bool hot_standby_feedback; +char *neon_storage_auth_token; /* libpqwalreceiver connection */ static WalReceiverConn *wrconn = NULL; diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index cabe0801548..dd280a397cb 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -71,6 +71,7 @@ #include "replication/slot.h" #include "replication/slotsync.h" #include "replication/syncrep.h" +#include "replication/walreceiver.h" #include "storage/bufmgr.h" #include "storage/large_object.h" #include "storage/pg_shmem.h" @@ -4799,6 +4800,17 @@ struct config_string ConfigureNamesString[] = check_restrict_nonsystem_relation_kind, assign_restrict_nonsystem_relation_kind, NULL }, + { + {"neon_storage_auth_token", PGC_SUSET, REPLICATION_STANDBY, + "Authentication token for Neon storage", + NULL, + GUC_SUPERUSER_ONLY + }, + &neon_storage_auth_token, + "", + NULL, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL, NULL diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index 12f71fa99b0..ebfdfe85c15 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -29,6 +29,7 @@ extern PGDLLIMPORT int wal_receiver_status_interval; extern PGDLLIMPORT int wal_receiver_timeout; extern PGDLLIMPORT bool hot_standby_feedback; +extern PGDLLIMPORT char *neon_storage_auth_token; /* * MAXCONNINFO: maximum size of a connection string.