Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJpM9-0004Pb-UP for pgsql-general@arkaria.postgresql.org; Tue, 28 Nov 2017 23:32:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJpM9-0004Qh-C7 for pgsql-general@arkaria.postgresql.org; Tue, 28 Nov 2017 23:32:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eJpM9-0004QV-4q for pgsql-general@lists.postgresql.org; Tue, 28 Nov 2017 23:32:01 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eJpM2-0006Mm-09 for pgsql-general@postgresql.org; Tue, 28 Nov 2017 23:32:00 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 6CD535F795; Tue, 28 Nov 2017 18:31:53 -0500 (EST) Date: Tue, 28 Nov 2017 18:31:53 -0500 From: Stephen Frost To: Susan Hurst Cc: pgsql-general@postgresql.org Subject: Re: User Connecting to Remote Database Message-ID: <20171128233153.GZ4628@tamriel.snowman.net> References: <36bb557d03ae8a3ab4508b3ce90e2b75@mail.brookhurstdata.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/UJ91r+FgXjwDQMF" Content-Disposition: inline In-Reply-To: <36bb557d03ae8a3ab4508b3ce90e2b75@mail.brookhurstdata.net> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --/UJ91r+FgXjwDQMF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings Susan, * Susan Hurst (susan.hurst@brookhurstdata.com) wrote: > I would welcome your comments and suggestions for connecting a user > (not a superuser) to a foreign server. >=20 > I have a database, named geo, in which I have geospatial and > geopolitical data. I want to be able to select data from geo from > other databases. >=20 > The database that I want to connect up to geo is named stp. I have > a foreign data wrapper in stp that defines geo as the data source > for the foreign server named geoserver. >=20 > User stp is defined in both geo and stp as superusers, so I am able > to select geo data just fine from stp. However, when I try to > select geo data as user geo_user, I get this error: >=20 > ERROR: permission denied for relation geoadm_l0 > SQL state: 42501 >=20 > What am I missing? Here are the relevant grants etc that I set up > in both geo and stp. >=20 > -- user and user mapping in stp database > create user geo_user with login nosuperuser inherit nocreatedb > nocreaterole noreplication password '**********'; > CREATE USER MAPPING FOR geo_user SERVER geoserver OPTIONS (password > '**********', "user" 'geo_user'); > grant usage on foreign data wrapper postgres_fdw to geo_user; > GRANT USAGE ON FOREIGN SERVER geoserver TO geo_user; >=20 > -- user in geo database > create user geo_user with login nosuperuser inherit nocreatedb > nocreaterole noreplication password '**********'; >=20 > -- grants in geo database > GRANT ALL ON TABLE public.geoadm_l0 TO susan; > GRANT SELECT ON TABLE public.geoadm_l0 TO geo_user; > GRANT SELECT ON TABLE public.geoadm_l0 TO read; > GRANT ALL ON TABLE public.geoadm_l0 TO geo; > GRANT INSERT, UPDATE, DELETE ON TABLE public.geoadm_l0 TO write; You don't appear to have done any GRANTs to the geo_user in the stp database..? Note that we check the privileges on the FOREIGN TABLE defined in the source database too. Thanks! Stephen --/UJ91r+FgXjwDQMF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaHfHoAAoJEO1sijiDR2RVaYoQAJx2KT/aWihANu5IDLsCtPmm gWg3XoC9DyftQyWxBbyK+HfPsbAxVitPriVYQ6mi4F0CVClX4A09YupaAyQW2fil Q24b6Pwy32Dmc0hEM33SF++sVz8vTX5vslDEzc+gyMm8N4CRpO0KfBypQcvNFUj6 HOZRIHFcBcnT9Jb9x/btbYVu9NiA1351RWRnjX4ki7vv9N2C+SGuFUizZckAhUU3 g/rkCwtZ5XTjNJNDVcBdWGRF7mZYxE35svNcvGbWXOn+u4WpaLktO8B3iXX3JCn4 P2TzRn0OTORmxUOVGtlV5AfCNtFT3fAJnJ6YvKfYLxiyZxKZP4vbihkC8Lh1lzE7 3P+gw9y5Q0xLAb+dJ7mhg6eXa5II5iDuzoabYM29oM23+YmHGc82yzE6IVsiH7aF yR1adpDYaCUIUABtdwNrb2QrQnmtrmk/VG3rvDCHE6inEDk/Zvy4VcJ33CsIzPkP i931avAPHP4IoV5awJZDErerpLnrwl8KILbU1BIh7PVZBFuQVaC544cDraOwldUw koE9ml18+SbafXEKg7GGucuDoIFthSogwthCEzFeADlHazVLHBTr66AMnUItspVa cYcJRhILGVvFEr6wVeSBLqjcfdJuGYhva63X1wrSTEfySkSld9FfvxneHgEfF5RF DN5yelm/EF7lBdTq6b9H =h2Ir -----END PGP SIGNATURE----- --/UJ91r+FgXjwDQMF--