How can I query what security labels exist on a table?

572 views Asked by At

Using the postgresql-anonymizer Postgres extension I've set security labels for masking on a number of columns.

e.g.

SECURITY LABEL FOR anon ON COLUMN "Customer"."firstName" IS 'MASKED WITH FUNCTION anon.fake_first_name()

I want a way to query if it's been added, and see what the label is. How do I do this?

1

There are 1 answers

0
Todd Drinkwater On BEST ANSWER

Query pg_seclabels to find the table and columns the labels are assigned to.

objname will contain the table and column e.g. "Users"."firstName", label, as the name gives away, will contain the label. e.g. 'MASKED WITH FUNCTION anon.fake_first_name()

  SELECT objname, label
  FROM pg_seclabels
  WHERE provider = 'anon';