aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/option.c
diff options
context:
space:
mode:
authorJacob Champion <jchampion@postgresql.org>2025-04-29 13:08:24 -0700
committerJacob Champion <jchampion@postgresql.org>2025-04-29 13:08:24 -0700
commitd2e7d2a09d7d17656418f8c859074db690af19ec (patch)
tree3d92c5b6cfe22d4ae1eaf8a1cec444be7dc12f1e /contrib/postgres_fdw/option.c
parent45363fca6372a04e90d1c2628c3cbfe8894b811b (diff)
downloadpostgresql-d2e7d2a09d7d17656418f8c859074db690af19ec.tar.gz
postgresql-d2e7d2a09d7d17656418f8c859074db690af19ec.zip
oauth: Disallow OAuth connections via postgres_fdw/dblink
A subsequent commit will reclassify oauth_client_secret from dispchar="" to dispchar="*", so that UIs will treat it like a secret. For our FDWs, this change will move that option from SERVER to USER MAPPING, which we need to avoid. But upon further discussion, we don't really want our FDWs to use our builtin Device Authorization flow at all, for several reasons: - the URL and code would be printed to the server logs, not sent over the client connection - tokens are not cached/refreshed, so every single connection has to be manually authorized by a user with a browser - oauth_client_secret needs to belong to the foreign server, but options on SERVER are publicly accessible - all non-superusers would need password_required=false, which is dangerous Future OAuth work can use FDWs as a motivating use case. But for now, disallow all oauth_* connection options for these two extensions. Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250415191435.55.nmisch%40google.com
Diffstat (limited to 'contrib/postgres_fdw/option.c')
-rw-r--r--contrib/postgres_fdw/option.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c
index d0766f007d2..c2f936640bc 100644
--- a/contrib/postgres_fdw/option.c
+++ b/contrib/postgres_fdw/option.c
@@ -348,6 +348,13 @@ InitPgFdwOptions(void)
strcmp(lopt->keyword, "client_encoding") == 0)
continue;
+ /*
+ * Disallow OAuth options for now, since the builtin flow communicates
+ * on stderr by default and can't cache tokens yet.
+ */
+ if (strncmp(lopt->keyword, "oauth_", strlen("oauth_")) == 0)
+ continue;
+
/* We don't have to copy keyword string, as described above. */
popt->keyword = lopt->keyword;