pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Dominique Devienne <ddevienne@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: "paths" between two ROLEs
Date: Tue, 13 Jun 2023 08:20:41 -0400
Message-ID: <ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com> (raw)
In-Reply-To: <CAFCRh-_NvCgXLSQ5w8XhXqyTo1ts5jG_WEYqwuvRdBVEyMpySQ@mail.gmail.com>
References: <CAFCRh-_NvCgXLSQ5w8XhXqyTo1ts5jG_WEYqwuvRdBVEyMpySQ@mail.gmail.com>

On 6/13/23 04:17, Dominique Devienne wrote:
> Hi. We emulated a legacy security model (enforced in C/C++ code)
> into "layers" of PostgreSQL ROLEs and GRANTs, thus enforced database-side.
> 
> To troubleshoot and validate that emulation, I'd like to introspect ROLE 
> membership to:
> 
> 1) Output the ROLE "path(s)" between any two ROLEs. Typically between 
> the LOGIN USER and the ROLE that control access to a particular SCHEMA. 
> In our model, there can be several ways the two end-roles are connected, 
> involving a variable number of roles. So it has to be a recursive query.
> 
> 2) target-end ROLEs (controlling access to SCHEMAs, again) follow a 
> naming convention, so they can be identified using a LIKE pattern. 
> Output all target ROLEs (aggregating each "paths" to the source-ROLE in 
> an text[]) a given LOGIN USER has access to.
> 
> I'd appreciate either example SQL for the above; or hints to achieve the 
> above.
> My CTE "foo" is not great, thus reaching out to the community to avoid 
> wasting too much time on this on my own.

This shows the path between roles taken which provides a particular 
privilege for a particular object:

https://github.com/CrunchyData/crunchy_check_access

It might do for you as-is, or at least you can use it as an example.

HTH,

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com






view thread (3+ messages)  latest in thread

Message-ID: <ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com>
Permalink:  ../ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com/
Also on:    postgresql.org/message-id/ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: mail@joeconway.com, ddevienne@gmail.com
  Subject: Re: "paths" between two ROLEs
  In-Reply-To: <ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com>
  References: <CAFCRh-_NvCgXLSQ5w8XhXqyTo1ts5jG_WEYqwuvRdBVEyMpySQ@mail.gmail.com> <ecc3930c-73e7-9807-2bef-141ea44cd9b5@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox