Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiGBA-0007BG-0a for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 11:43:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jiGB8-00018E-Py for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 11:42:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiGB8-000187-FK for pgsql-general@lists.postgresql.org; Mon, 08 Jun 2020 11:42:58 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jiGB6-0000nY-1x for pgsql-general@lists.postgresql.org; Mon, 08 Jun 2020 11:42:57 +0000 Received: by mail-wr1-x443.google.com with SMTP id x14so17043199wrp.2 for ; Mon, 08 Jun 2020 04:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=h5+ZcIgPfSk4FpY2JMeWw6a5Stw47EIK1BhezAk6fN0=; b=O0nbJmR5wbW4opMljRTyOJNi+iicXqDcdOlaBm2Bjg/8iqU1v375WI0I8t5Awrtyg5 9KHB3mBa41YYM46CYPxOfkG25NmhSup1+bwQf5O7+Z1i4kM6U03+CM2t+aTQahuOEco9 //aCX5sTSzaDuTnUNbU6z5er2QqggzElQI4BbRALAacjwERnMyDA/BhLWLFpoQs4Gv02 1AnK/4LFjD6tVMRxtXyMzkXkxt85gLRHOC90/OllvtOXLsQ+uvD9WvvKWjck/uVmLBZE rvrIg0CzknsoTZWkwNfO/bQWp/ihAwBwczRRvic9xqu+o7uzjn73hizuOvu3/UIMfFkl YulA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=h5+ZcIgPfSk4FpY2JMeWw6a5Stw47EIK1BhezAk6fN0=; b=EPhqnx+43Mhp34Jo5X71j1NMQtoGlaJ3hc3MP6Zoz5ZUe+wytLFe2HNPy08z7gUzda OfU2t6KF5uM8jLPtGppJky/rzmQr2vy5Mrjo5R2OdVyjNgPHu5oEp9GxxP5JoNdEJcgM ERryKspfCGiImG79bhfPeR/3cCs9+hewPknYxFC8A2AFmueStMmK/4DjaWE4A96oUJ77 K5uQ2Dm1yTK7Nfpka4K4yNKGdrJJBppqbA0iqL0plH3g7E+SIwAu/0i99cuquD9f+UXG EZWYceiMqd6gDpaGp9MkWYLJ5VYLYNcz9j8bSTw6qKsulEcFOljflPjJn0nGHPQ69OxP b4Xw== X-Gm-Message-State: AOAM530si9mzfRORgYI7IYzc6uagSYkxyin1Fw2ZvCT+Htqb1YF1MOqh RsdJZMyjbtf7eduiSG2bMMs= X-Google-Smtp-Source: ABdhPJwLWkIjM1WVeVRN0iZkQYj4mB/XaIbquOcxgVrwXIlV5C7Qk1AJaVQh4FeHWIbu6xXEyzg5Iw== X-Received: by 2002:adf:c98a:: with SMTP id f10mr23026471wrh.329.1591616573784; Mon, 08 Jun 2020 04:42:53 -0700 (PDT) Received: from [192.168.1.8] (241-57-239-77.dyn.cable.fcom.ch. [77.239.57.241]) by smtp.gmail.com with ESMTPSA id a15sm24256294wra.86.2020.06.08.04.42.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jun 2020 04:42:53 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: Postgres 12 RLS From: =?utf-8?Q?Paul_F=C3=B6rster?= In-Reply-To: Date: Mon, 8 Jun 2020 13:42:50 +0200 Cc: postgre Content-Transfer-Encoding: quoted-printable Message-Id: <7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com> References: To: Laura Smith X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Laura, > On 08. Jun, 2020, at 12:46, Laura Smith = I had a lightbulb moment just now = and tried that, but it doesn't seem to be working. >=20 > The app returns "pg_execute(): Query failed: ERROR: permission denied = for table...." >=20 > This is despite me: > =E2=80=A2 Changing to SECURITY INVOKER on the PG function. > =E2=80=A2 Granting the app user relevant perms on the underlying table > =E2=80=A2 Re-granting execute for the app on the function >=20 > Am I missing somehthing ? another possibility maybe is to use session_user instead of current_user = in your policy. current_user name user name of current execution context session_user name session user name The latter is the name of the user who actually started the session. So = it should be myappuser in your case. https://www.postgresql.org/docs/current/functions-info.html Cheers, Paul=