Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf5fd995

Browse files
committed
Allow 'sslkey' and 'sslcert' in postgres_fdw user mappings
This allows different users to authenticate with different certificates.Author: Craig Ringer
1 parent45223fd commitf5fd995

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ WARNING: extension "bar" is not installed
174174
ALTER SERVER testserver1 OPTIONS (DROP extensions);
175175
ALTER USER MAPPING FOR public SERVER testserver1
176176
OPTIONS (DROP user, DROP password);
177+
-- Attempt to add a valid option that's not allowed in a user mapping
178+
ALTER USER MAPPING FOR public SERVER testserver1
179+
OPTIONS (ADD sslmode 'require');
180+
ERROR: invalid option "sslmode"
181+
HINT: Valid options in this context are: user, password, sslpassword, password_required, sslcert, sslkey
182+
-- But we can add valid ones fine
183+
ALTER USER MAPPING FOR public SERVER testserver1
184+
OPTIONS (ADD sslpassword 'dummy');
185+
-- Ensure valid options we haven't used in a user mapping yet are
186+
-- permitted to check validation.
187+
ALTER USER MAPPING FOR public SERVER testserver1
188+
OPTIONS (ADD sslkey 'value', ADD sslcert 'value');
177189
ALTER FOREIGN TABLE ft1 OPTIONS (schema_name 'S 1', table_name 'T 1');
178190
ALTER FOREIGN TABLE ft2 OPTIONS (schema_name 'S 1', table_name 'T 1');
179191
ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 OPTIONS (column_name 'C 1');

‎contrib/postgres_fdw/option.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ InitPgFdwOptions(void)
194194
{"fetch_size",ForeignServerRelationId, false},
195195
{"fetch_size",ForeignTableRelationId, false},
196196
{"password_required",UserMappingRelationId, false},
197+
/*
198+
* sslcert and sslkey are in fact libpq options, but we repeat them
199+
* here to allow them to appear in both foreign server context
200+
* (when we generate libpq options) and user mapping context
201+
* (from here).
202+
*/
203+
{"sslcert",UserMappingRelationId, true},
204+
{"sslkey",UserMappingRelationId, true},
205+
197206
{NULL,InvalidOid, false}
198207
};
199208

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ ALTER SERVER testserver1 OPTIONS (DROP extensions);
188188
ALTERUSER MAPPING FOR public SERVER testserver1
189189
OPTIONS (DROP user, DROP password);
190190

191+
-- Attempt to add a valid option that's not allowed in a user mapping
192+
ALTERUSER MAPPING FOR public SERVER testserver1
193+
OPTIONS (ADD sslmode'require');
194+
195+
-- But we can add valid ones fine
196+
ALTERUSER MAPPING FOR public SERVER testserver1
197+
OPTIONS (ADD sslpassword'dummy');
198+
199+
-- Ensure valid options we haven't used in a user mapping yet are
200+
-- permitted to check validation.
201+
ALTERUSER MAPPING FOR public SERVER testserver1
202+
OPTIONS (ADD sslkey'value', ADD sslcert'value');
203+
191204
ALTER FOREIGN TABLE ft1 OPTIONS (schema_name'S 1', table_name'T 1');
192205
ALTER FOREIGN TABLE ft2 OPTIONS (schema_name'S 1', table_name'T 1');
193206
ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 OPTIONS (column_name'C 1');

‎doc/src/sgml/postgres-fdw.sgml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@
107107
A foreign server using the <filename>postgres_fdw</filename> foreign data wrapper
108108
can have the same options that <application>libpq</application> accepts in
109109
connection strings, as described in <xref linkend="libpq-paramkeywords"/>,
110-
except that these options are not allowed:
110+
except that these options are not allowed or have special handling:
111111

112112
<itemizedlist spacing="compact">
113113
<listitem>
114114
<para>
115115
<literal>user</literal>, <literal>password</literal> and <literal>sslpassword</literal> (specify these
116-
in a user mapping, instead)
116+
in a user mapping, instead, or use a service file)
117117
</para>
118118
</listitem>
119119
<listitem>
@@ -128,6 +128,14 @@
128128
<literal>postgres_fdw</literal>)
129129
</para>
130130
</listitem>
131+
<listitem>
132+
<para>
133+
<literal>sslkey</literal> and <literal>sslpassword</literal> - these may
134+
appear in <emphasis>either or both</emphasis> a connection and a user
135+
mapping. If both are present, the user mapping setting overrides the
136+
connection setting.
137+
</para>
138+
</listitem>
131139
</itemizedlist>
132140
</para>
133141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp