Inteli Logo

Module 8 · Information Systems · Lesson 13 · Lab

Data security in the browser

PostgreSQL 18 runs inside this page (PGlite). The schema shop holds the customers and orders of a fictitious card shop with three stores; every person in it is synthetic. The session is the superuser postgres, and SET ROLE plays each job of the DataApp. Every statement that changes the database, a SET ROLE included, is kept in the localStorage and replayed in order on the next visit. Every date is Unix time, in seconds.

PostgreSQL: loading shop: waiting policy: waiting acting as: —
Step 01 · 6 min

Classify

Every column under LGPD art. 5: personal, sensitive or not, with purpose, legal basis and retention.

Step 02 · 6 min

Roles

One role per job, nothing for PUBLIC, and the privilege matrix of least privilege.

Step 03 · 7 min

Row level security

Each manager reads only the own store; FORCE makes the owner obey too.

Step 04 · 7 min

Masking

A peppered key instead of the customer, generalised ages and an aggregate with k = 5.

Step 05 · 7 min

Audit log

Who changed or read what, when and why, in an append-only log without personal data.

Step 06 · 7 min

Access tests

Nine probes as seven roles, against the policy written before, and a regression on purpose.

Second hour · groups

Your DataApp in ClickHouse

Inventory, roles, row policies and pseudonyms for the partner data in lab.gNN_ on shrek2.

Shortcuts

Roles of the session

Run a query as a job without typing SET ROLE; the badge above shows who is acting.

Ctrl+Enter runs every statement · one result per statement

Access matrix

Each cell runs one probe as one role, inside a transaction that is rolled back, and compares the outcome with gov.expected_access: denied is an error, none is zero rows, some is fewer rows than the superuser sees and all is every row. A cell that disagrees with the policy is marked as a failure, which is how a careless GRANT shows up.

matches the policydiffers from the policy
Prompt