How would you handle permissions and security on sensitive data sets?
Translate the access policy into a PostgreSQL query that returns only currently authorized dataset grants. Sensitive datasets require an active user, enabled MFA, and an approved security role. Standard datasets require only an active user and a valid grant.
Output
- One row per authorized grant
- Columns:
email, dataset_name, classification, permission_level, granted_role, and access_scope
- Exclude inactive users, inactive datasets, revoked grants, expired grants, and unauthorized sensitive access
- Order by
email, then dataset_name
Output details
- Treat
DATE '2026-01-15' as today's date.
- Treat
public and internal classifications as standard, and restricted and secret classifications as sensitive.
- Require sensitive access to users whose
role is security_admin or data_protection, with mfa_enabled true.
- Treat grants with
revoked_at NULL and expires_at NULL or on/after DATE '2026-01-15' as valid.
- Derive
access_scope as sensitive for restricted or secret, otherwise standard.
- Sort
email and then dataset_name in ascending order without an additional tie-breaker.