Instruction session · Thursday, December 17, 2026 · one hour of demonstration, one hour in groups
The DataApp of a fictitious card shop keeps names, e-mails, CPFs and one health datum of its customers. In six steps, in a PostgreSQL that runs inside the browser, the data is classified under the LGPD, divided among roles of least privilege, filtered by row, pseudonymised for the analysts, audited, and finally tested as a matrix of who may do what.
Project ritual
Each group reports the progress of its deliverables, the work planned for this session and the blockers that require a decision.
In the first hour the professor applies six controls to the card shop, live, with a coding agent and the lab of the browser. In the second hour each group applies the same controls to the partner data in the ClickHouse of the class.
gov.data_catalogInventory of every column, purpose and retentionCREATE ROLE, GRANTOne role per job; least privilegeCREATE POLICYEach manager sees only the own storeanalytics.*Pepper, generalisation and k = 5audit.eventsWho changed or read what, and whygov.access_test()The policy as an automated testThe Lei Geral de Proteção de Dados (Law 13,709/2018) applies to every operation on personal data done in Brazil or about people in Brazil. A DataApp that collects, stores, combines or publishes such data is processing it, and its team answers for how.
| Concept | Article | In the card shop |
|---|---|---|
| personal data: identifies a person or makes the person identifiable | art. 5, I | name, e-mail, CPF, phone, birth date, the customer id |
| sensitive personal data: health, religion, ethnicity, biometrics and others | art. 5, II | the accessibility need of 5 customers |
| anonymised data: can no longer be linked to a person by reasonable means | art. 5, III; art. 12 | sales by store and age band, with at least 5 customers per group |
| principles: purpose, necessity, security, prevention, accountability | art. 6 | each column with a purpose; analytics without what it does not need |
| legal bases: consent, legal obligation, contract, legitimate interest | art. 7; art. 11 | the CPF by legal obligation; the health datum only with specific consent |
| security measures and a record of the operations | arts. 37 and 46 | roles, row policies, an audit log |
Data governance assigns to each person a job with duties over the data. The database enforces those duties only when each job is a role with its own privileges, and the six steps of the lab build that correspondence.
| Job in governance | Role in the lab | May | May not |
|---|---|---|---|
| custodian of the platform | app_owner | own the tables and change their structure | read a row without a policy (FORCE) |
| the ETL of the DataApp | etl_writer | insert customers and orders | read what it wrote |
| data steward of a store | manager_sp, _rj, _bh | read the own store; look up a contact with a purpose | see another store |
| analyst | analyst | read pseudonymised views | read a name, an e-mail or a CPF |
| consumer of a dashboard | dashboard | read the anonymised aggregate | read anything else |
| encarregado (DPO) | dpo | read the inventory and the audit log | read the personal data itself |
The lab runs PostgreSQL 18 compiled to WebAssembly (PGlite 0.5.10). The session is the superuser postgres, and SET ROLE plays each role, so every grant and policy can be proven by switching role and running the same query.
| Table | Rows | Personal data |
|---|---|---|
shop.stores | 3 | none |
shop.customers | 60 | name, e-mail, CPF, phone, birth date, city, accessibility need, consent |
shop.orders | 400 | the customer, the moment and the last 4 digits of the card |
example.com and every CPF starts with 000. Card names and prices come from the TCGplayer capture of Lesson 6.SET ROLE included, is kept in the localStorage and replayed in order. The access matrix at the bottom of the page runs the test of step 06.Step 01 · 0:20 · Classify
A column without a category, a purpose, a legal basis and a retention has no reason to be kept. The inventory is a table of the database, so that the next steps and the tests can read it.
gov.data_catalog with one row per column of shop, two tests of completeness and a summary by category.
accessibility_need sensitive, with consent as its basis?[C] Character
You are the data protection engineer of a DataApp. A fictitious card shop
with three stores (sp, rj, bh) sells TCGplayer cards and keeps its customers
and orders in PostgreSQL. Before anybody gets access to anything, you
classify every column under the LGPD (Law 13,709/2018).
[R] Request
1. docs/data_inventory.md: for each column of shop.stores, shop.customers
and shop.orders, its category under art. 5 (personal, sensitive,
anonymous or operational), whether it is a direct identifier, a
quasi-identifier or neither, the purpose, the legal basis of art. 7 or
art. 11, the retention in days and what the analytics layer does with it
(keep, pseudonymise, generalise or drop), justified by the principle of
necessity of art. 6, III.
2. sql/01_classify.sql, schema gov:
- table gov.data_catalog with those eight attributes, CHECK constraints
on the closed lists, primary key (table_name, column_name), and one
row per column;
- COMMENT ON COLUMN for the sensitive column and for the CPF;
- test 1: the columns of shop that are not in the catalogue (no rows);
- test 2: the rows of the catalogue that are not columns of shop (no rows);
- a summary of the columns by category and by analytics decision.
Facts measured on 08/11/2026 (confirm before use):
- 3 stores, 60 customers, 400 orders; 25 columns in the three tables.
- accessibility_need is health data, so sensitive (art. 5, II); 5 customers
have it filled.
[E] Example
shop.customers(customer_id, store_id, full_name, email, cpf, phone,
birth_unix, city, accessibility_need, marketing_consent, consent_unix,
created_unix)
('customers', 'cpf', 'personal', 'direct', 'issue the invoice',
'art. 7, II: legal obligation', 1825, 'drop')
[A] Adjustments
- The data is synthetic: every person is fake, the e-mails use the reserved
domain example.com and the CPFs start with 000. Never write a real person.
- An internal id that links rows to a person is still personal data.
- A quasi-identifier alone does not identify, but a few of them together
do (birth date, city, store): mark them, step 04 generalises them.
- Every date is Unix time in seconds (BIGINT).
- The script is pasted into the lab page and runs in PGlite 0.5.10
(PostgreSQL 18 compiled to WebAssembly) as the superuser postgres.
[T] Type of output
The two files and nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
The principle of necessity (art. 6, III) turns the inventory into a decision per column: keep it, pseudonymise it, generalise it or drop it from the analytics layer. Step 04 implements exactly these decisions.
| Category | Analytics | Columns | Which |
|---|---|---|---|
| sensitive | drop | 1 | accessibility_need |
| personal | drop | 7 | full name, e-mail, CPF, phone, city, consent date, card last 4 |
| personal | pseudonymise | 2 | customer_id of customers and of orders |
| personal | generalise | 3 | birth date, customer since, moment of the order |
| personal | keep | 2 | store of the customer, marketing consent |
| operational | keep | 10 | products, quantities, prices, stores, payment method |
Step 02 · 0:26 · Roles
Least privilege gives each job only what its purpose needs. People change and jobs stay, so privileges are granted to jobs, and a person receives a job by membership.
Ten roles, the tables owned by app_owner, the REVOKE from PUBLIC, the schemas analytics and audit, the grants and the privilege matrix.
store_manager?shop keep a privilege of PUBLIC?[C] Character
You are the data protection engineer of the card shop of step 01. The
inventory is done; now you decide who may touch what, by least privilege.
[R] Request
1. docs/access_policy.md: the jobs of the DataApp and, for each one, what it
needs and why: app_owner (owns the tables, not a superuser), etl_writer
(the ETL: inserts customers and orders, reads only the stores),
analytics_owner (owns the pseudonymised views, BYPASSRLS), analyst
(reads only analytics), dashboard (reads only the anonymised aggregate),
store_manager (reads its own store) and dpo (the encarregado of art. 41:
reads the catalogue and the audit log); and one person per store,
manager_sp, manager_rj and manager_bh, members of store_manager.
2. sql/02_roles.sql:
- every role NOLOGIN; the people receive the job with IN ROLE;
- schema shop and its tables owned by app_owner;
- REVOKE ALL from PUBLIC on the schema public, on the tables of shop
and of gov;
- schemas analytics (AUTHORIZATION analytics_owner) and audit;
- the GRANTs of each job, and ALTER DEFAULT PRIVILEGES so that every
view analytics_owner creates in analytics is readable by analyst;
- the privilege matrix with has_table_privilege for five roles and three
tables;
- SET ROLE etl_writer, the proof that it inserts but cannot select
customers, RESET ROLE.
[E] Example
CREATE ROLE store_manager NOLOGIN;
CREATE ROLE manager_sp NOLOGIN IN ROLE store_manager;
GRANT SELECT ON shop.customers TO store_manager;
[A] Adjustments
- One role per job, never per person; a person is a member of a job.
- Nothing is granted to PUBLIC; a function is executable by PUBLIC by
default, which step 03 and step 05 revoke.
- A schema needs USAGE before any table of it can be read.
- PGlite has one session, the superuser postgres: SET ROLE plays each role
and RESET ROLE comes back. End the script with RESET ROLE.
[T] Type of output
The two files and nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
PostgreSQL checks the privilege of the schema first and of the table after it, and a new function is executable by PUBLIC by default. A grant left to PUBLIC is a grant to every user, present and future.
CREATE ROLE manager_sp NOLOGIN IN ROLE store_manager: the privileges belong to store_manager, and replacing a manager is one membership, not a review of every grant.
The ETL inserts customers and orders but cannot select them. A leaked password of the ETL then exposes no customer, which is the point of least privilege.
ALTER DEFAULT PRIVILEGES FOR ROLE analytics_owner IN SCHEMA analytics GRANT SELECT ON TABLES TO analyst: every view created later is readable by the analysts, without a forgotten grant.
| Role | shop.customers | shop.orders | gov.data_catalog |
|---|---|---|---|
etl_writer | insert | insert | none |
manager_sp | select | select | none |
analyst, dashboard | none | none | none |
dpo | none | none | select |
Step 03 · 0:32 · Row level security
GRANT gave the managers the table of customers; a policy now decides which rows of it each one sees. The rule lives in the database, so it holds for every client: the lab, a notebook or a dashboard.
gov.store_staff, gov.actor(), gov.my_stores(), RLS enabled and forced on customers and orders, the policies and the proof with three roles.
[C] Character
You are the data protection engineer of the card shop. GRANT decided the
tables each job reads; now row level security decides the rows, so that a
store manager sees only the customers and orders of the own store.
[R] Request
1. sql/03_row_security.sql:
- table gov.store_staff (role_name, store_id) with the three managers;
- function gov.actor(): the role that is acting, read from
current_setting('role') and, when there is no SET ROLE, session_user;
- function gov.my_stores(), SECURITY DEFINER with a fixed search_path,
executable only by store_manager, returning the stores of the actor;
- ENABLE and FORCE ROW LEVEL SECURITY on shop.customers and shop.orders;
- a SELECT policy for store_manager over gov.my_stores(), and an INSERT
policy for etl_writer that accepts only existing stores;
- the proof: the same query of orders and revenue by store as
manager_sp, as manager_rj and as the superuser; and app_owner seeing
zero customers because of FORCE.
2. docs/access_policy.md: a section on RLS, with the anti-pattern of a
policy over a setting that the user can change (SET app.store_id).
Facts measured on 08/11/2026 (confirm before use):
- orders by store: sp 162 (US$ 58,258.08), rj 128 (US$ 65,629.66),
bh 110 (US$ 12,371.59).
[E] Example
CREATE POLICY manager_reads_own_store ON shop.orders
FOR SELECT TO store_manager
USING (store_id IN (SELECT gov.my_stores()));
[A] Adjustments
- Inside a SECURITY DEFINER function current_user is the owner of the
function, not the caller: use gov.actor().
- The superuser and the roles with BYPASSRLS ignore every policy; FORCE
makes the owner of the table obey them.
- A table with RLS and no policy for a role shows no row to that role.
- End the script with RESET ROLE.
[T] Type of output
The SQL file and the new section, nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
With RLS on, a row is visible only when some policy of the role is true for it. The superuser and the roles with BYPASSRLS ignore policies, and FORCE makes even the owner of the table obey them.
| Acting as | Stores seen | Orders | Revenue, US$ |
|---|---|---|---|
manager_sp | sp | 162 | 58,258.08 |
manager_rj | rj | 128 | 65,629.66 |
postgres (superuser) | sp, rj, bh | 400 | 136,259.33 |
app_owner (owner, FORCE) | none | 0 | — |
CREATE POLICY manager_reads_own_store
ON shop.orders
FOR SELECT TO store_manager
USING (store_id IN
(SELECT gov.my_stores()));USING (store_id = current_setting('app.store_id')), is defeated by SET app.store_id = 'rj'. It is safe only when the application is the sole client and the users never write SQL; the lab reads the acting role instead, which a user cannot forge.Step 04 · 0:39 · Masking
The analytics layer receives a key instead of the customer, an age band instead of the birth date and the day instead of the moment. The dashboard receives only groups with at least five customers.
gov.pepper, the views analytics.customers_pseudo, orders_pseudo and sales_by_segment, owned by analytics_owner.
shop?[C] Character
You are the data protection engineer of the card shop. The analysts need
sales by customer profile, never the name, the e-mail or the CPF of a
customer.
[R] Request
1. sql/04_masking.sql:
- table gov.pepper with one random secret, readable only by
analytics_owner;
- as analytics_owner, three views in analytics:
- customers_pseudo: customer_key (the first 16 hex characters of the
SHA-256 of pepper || ':' || customer_id), store_id, age_band
(18-24, 25-34, 35-49, 50+), email_masked (first letter, ***, domain),
marketing_consent and the day the customer arrived, in Unix time;
- orders_pseudo: the order with customer_key instead of customer_id,
the day in Unix time and no card_last4;
- sales_by_segment: customers, orders and revenue by store and age
band, suppressing every group with fewer than 5 distinct customers;
- SELECT on sales_by_segment for dashboard;
- as analyst, eight rows of customers_pseudo and the whole aggregate;
- how many segments k = 5 suppressed and how many customers were in them.
2. docs/data_inventory.md: a section on the difference between pseudonymised
data (still personal, art. 13, §4) and anonymised data (art. 5, III and
art. 12), and where the pepper lives in production.
Facts measured on 08/11/2026 (confirm before use):
- 7 segments published, 4 suppressed with 7 customers in them.
[E] Example
SELECT left(encode(sha256(convert_to(p.value || ':' || c.customer_id,
'UTF8')), 'hex'), 16) AS customer_key
FROM shop.customers AS c CROSS JOIN gov.pepper AS p
[A] Adjustments
- A hash of the id without a secret is reversible by brute force: 60 ids
take 60 hashes.
- A view runs with the privileges of its owner, so the analyst reads the
view without any GRANT on shop.
- PGlite has sha256() and md5() built in; there is no pgcrypto.
- Every date is Unix time in seconds; the day is ts / 86400 * 86400.
- End the script with RESET ROLE.
[T] Type of output
The SQL file and the new section, nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
The LGPD draws the line by the possibility of linking the data back to the person. A key that a secret can reverse is pseudonymisation (art. 13, §4) and the law still applies; an aggregate that no reasonable means links to a person is anonymised (art. 12).
sha256(pepper || ':' || customer_id), cut to 16 hex characters. Without the pepper, a hash of the id alone is reversed by computing the hash of the 60 possible ids.
The birth date becomes 18-24, 25-34, 35-49 or 50+; the moment of the order becomes its day, ordered_unix / 86400 * 86400; the e-mail becomes a***@example.com.
A store and age band with fewer than five customers is not published. Of 11 segments, 7 are published and 4 are suppressed, with 7 customers in them.
analytics_owner reads. In production it is a secret of the server or an environment variable outside the repository, because whoever holds the pepper and the keys can reverse every pseudonym.Step 05 · 0:46 · Audit log
The LGPD asks the controller to record its operations on personal data (art. 37). Changes are caught by a trigger; reads of contact data, which no trigger sees, happen only through a function that demands a purpose.
audit.events (append-only), the trigger audit.log_change(), the function shop.lookup_customer(id, purpose) and three events read by the DPO.
[C] Character
You are the data protection engineer of the card shop. The LGPD asks the
controller to keep a record of the operations on personal data (art. 37);
you write the audit log of the DataApp.
[R] Request
1. sql/05_audit.sql:
- table audit.events (event_id, at_unix, actor, action, table_name,
row_key, purpose, columns), readable only by dpo;
- a trigger that refuses every UPDATE and DELETE of audit.events;
- a SECURITY DEFINER trigger on shop.customers that logs every INSERT,
UPDATE and DELETE with the actor and the names of the changed columns,
never their values;
- function shop.lookup_customer(customer_id, purpose), SECURITY DEFINER,
the only door to name, e-mail and phone: it refuses who is not a store
manager, a purpose shorter than 10 characters and a customer of another
store, and logs a READ event with the purpose; EXECUTE revoked from
PUBLIC and granted to store_manager;
- three events: manager_sp looks up customer 1, etl_writer inserts
customer 61, the superuser corrects the e-mail of customer 1;
- as dpo, the log and the count of events by actor and action.
[E] Example
INSERT INTO audit.events (actor, action, table_name, row_key, columns)
VALUES (gov.actor(), TG_OP, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME,
rec ->> 'customer_id', changed);
[A] Adjustments
- A trigger never sees a SELECT: reads of personal data are logged by the
function that serves them.
- The log is append-only and holds no personal data besides the key of the
row, otherwise it becomes a second copy to protect.
- at_unix is Unix time in seconds (extract(epoch FROM now())::bigint).
- Fix the search_path of every SECURITY DEFINER function.
- End the script with RESET ROLE.
[T] Type of output
The SQL file and nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
The actor is the role that was acting, read inside the SECURITY DEFINER function from current_setting('role'), because there current_user is the owner of the function and would hide who called it.
| Actor | Action | Row | Purpose | Columns |
|---|---|---|---|---|
manager_sp | READ | customer 1 | Notify the customer that a reserved order arrived | email, full_name, phone |
etl_writer | INSERT | customer 61 | — | the 12 columns of the row |
postgres | UPDATE | customer 1 | — |
Writing the old and new values would make the log a second store of e-mails and CPFs, with its own retention and its own leaks. It keeps the key of the row and the names of the columns.
A trigger refuses every UPDATE and DELETE of audit.events, the owner included. The superuser could drop the trigger, and that DDL is itself an event to watch.
The repository of these lessons is public, so any exam written in it would be readable days before the class. The statement lives in the PostgreSQL of the course, behind PostgREST, with the same controls of the lab.
The tables of the exam have RLS enabled and no policy at all, plus REVOKE ALL from the public roles of the API. No call reads a row of them directly.
prova_abrir(slug, token)A SECURITY DEFINER function with a fixed search_path compares the SHA-256 of the token typed by the professor with the hash it keeps. The token in clear exists in no table, no file and no page.
Each attempt, right or wrong, is a row of a log. A refusal returns {"ok": false} instead of raising an error, because an error rolls back the transaction and the record of the attempt with it.
The SQL that loads each exam sits in a folder that git ignores, and the database password in the environment file of the infrastructure. After eight wrong tokens in five minutes the function refuses, but never the right token.
shop.lookup_customer raises an error when it refuses, so a refused lookup leaves no event. Making refusals visible to the DPO is the exercise the case suggests.Step 06 · 0:53 · Access tests
A policy that nobody tests drifts with the next GRANT. The expected access of each role is a table, written from the policy before the first run, and a function runs every probe as every role and compares.
gov.probes, gov.try_as(role, sql), gov.expected_access, gov.access_test(), the verdict, the matrix and a regression on purpose.
[C] Character
You are the data protection engineer of the card shop. A policy that nobody
tests drifts with the next GRANT, so you turn the access policy into an
automated test that runs every probe as every role.
[R] Request
1. sql/06_access_tests.sql:
- table gov.probes (probe, ord, sql) with nine probes: read customers,
read orders, insert customer, lookup contact, read pseudonyms, read
segments, read pepper, read audit log, erase audit log;
- function gov.try_as(role, sql): runs the statement first as the
superuser and then under SET LOCAL ROLE, each time inside a
subtransaction that is always rolled back, and returns denied (error),
none (0 rows), some (fewer rows than the superuser) or all;
- table gov.expected_access with the expected outcome of the nine probes
for etl_writer, manager_sp, manager_rj, analyst, dashboard, dpo and
app_owner, written from docs/access_policy.md before running anything;
- function gov.access_test() returning role, probe, ord, expected,
observed and pass;
- the verdict (pairs, passed, failed) and the matrix with one row per role;
- a regression on purpose: GRANT USAGE on shop and SELECT on all its
tables to analyst, the failing pairs, the REVOKE, and the test green again.
2. tests/test_access.py: the same verdict run by pytest against the
PostgreSQL of the project, failing when any pair fails.
Facts measured on 08/11/2026 (confirm before use):
- 63 pairs, 63 passed. After the careless GRANT: analyst reads customers
and orders as none instead of denied, 2 failures.
[E] Example
BEGIN
EXECUTE format('SET LOCAL ROLE %I', p_role);
EXECUTE p_sql; GET DIAGNOSTICS n = ROW_COUNT;
RAISE EXCEPTION USING ERRCODE = 'P0001', MESSAGE = 'rollback';
EXCEPTION WHEN raise_exception THEN ...
[A] Adjustments
- The expectations come from the policy, never from a first run of the test.
- A probe that raises an exception of its own (P0001 with another message)
is denied.
- The rollback also removes the events that a successful probe would write
to the audit log.
[T] Type of output
The two files and nothing else.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Each probe runs first as the superuser and then as the role, inside a subtransaction that always rolls back. Its outcome is denied (an error), none (zero rows), some (fewer rows than the superuser) or all.
| Role | read customers | read orders | insert customer | lookup contact | read pseudonyms | read segments | read audit log |
|---|---|---|---|---|---|---|---|
etl_writer | denied | denied | all | denied | denied | denied | denied |
manager_sp | some | some | denied | all | denied | denied | denied |
manager_rj | some | some | denied | denied | denied | denied | denied |
analyst | denied | denied | denied | denied | all | all | denied |
dashboard | denied | denied | denied | denied | denied | all | denied |
dpo | denied | denied | denied | denied | denied | denied | all |
app_owner | none | none | denied | denied | denied | denied | denied |
GRANT USAGE ON SCHEMA shop and GRANT SELECT ON ALL TABLES IN SCHEMA shop TO analyst, the analyst reads customers and orders as none instead of denied: RLS still hid every row, but the test fails twice, because the policy demands that the first layer holds too.Each group applies the controls to the partner data in the ClickHouse of the class (shrek2), database lab, objects gNN_, with prompt 07 of the lab.
docs/data_inventory.md: every field classified, with the analytics decisiondocs/access_policy.md: the jobs and their expected accesssql/clickhouse/security.sql: roles, grants, row policies, a pseudonymised view and an aggregate with k = 5docs/audit.md: the reads of the personal tables in system.query_logCREATE ROLE g01_analyst; GRANT SELECT ON lab.g01_fact_sales TO g01_analyst; CREATE ROW POLICY g01_by_state ON lab.g01_fact_sales USING state = 'SP' TO g01_analyst; SHOW GRANTS FOR g01_analyst;
The user of the group may lack ACCESS MANAGEMENT: the access statements are a reference that the administrator runs.
Module 8 built one DataApp over the prices of TCGplayer: a model, a package, a scheduler, tests, metrics, infographics and a cost. This last lesson adds the condition for any of it to reach real people's data.
| Control | Question it answers | Where in the lab |
|---|---|---|
| inventory | what personal data do we keep, why, and for how long? | gov.data_catalog |
| roles and grants | which job reaches which table? | CREATE ROLE, GRANT, REVOKE ... FROM PUBLIC |
| row policies | which rows of the table does each job see? | CREATE POLICY, FORCE ROW LEVEL SECURITY |
| masking | what does analysis need of each person? | analytics.*, pepper, k = 5 |
| audit | who touched which person's data, and why? | audit.events, shop.lookup_customer |
| tests | does the policy still hold after the last change? | gov.access_test() |
Readings and a video assigned on Adalove, on the principles of data protection that the GDPR and the LGPD share, with the reading material of the session.
Core GDPR principles, from lawful processing and minimisation to integrity and accountability.
Video on GDPR security requirements and practical steps towards compliance.
The seven core GDPR principles explained with examples and good practices. The reading material of this session is Lesson 13 material.
Data Security, Authorizations, and Access · 17/12/2026 · Prof. Afonso
By the end of the session, students should be able to classify the personal data of a DataApp under the LGPD and implement, in the database, the access controls that follow from it (roles of least privilege, row level security, pseudonymisation with k-anonymity and an append-only audit log), verifying them with an automated access test, first in the card shop of the lab and then on the partner data in ClickHouse.
Demonstration followed by application. In the first hour the professor applies six controls to the DataApp of a fictitious card shop, live, with a coding agent and six CREATE prompts, in a PostgreSQL (PGlite) that runs inside the browser, proving each control with SET ROLE and closing with a case study of how this portal protects its exams. In the second hour each group applies the same controls to the partner data in the ClickHouse of the class (shrek2) with the seventh prompt.