Permissions belong in the database, not behind a hidden button
By Muhammad Umer Khan · Built Jun 2026 to now
Published
I am the main developer of a white-label platform that runs a housing society: residents, visitors, staff, complaints and the gate. It is live with its first society. I joined a two-person team after the first release, so this is about the parts I built, and the rule behind all of them: a permission that only lives in the app is a suggestion. It has to live in the database.
What was there before me
The original developer built the core: signed QR passes that validate offline, the offline scan queue, the licence check and the audit log. I joined after the first release, at Revera Innovations, and have been the main developer since June 2026. Each society runs on its own Supabase project, with its own web build and mobile build.
A hidden button is not access control
A society wants to hand complaints to one person and visitors to another, without giving either of them everything. I consolidated the platform to four roles and added scoped sub-admins. A super-admin grants sections, and the database enforces each grant through row-level security, so a sub-admin cannot read or write a section it was not given, even by calling the API directly.
The pattern, simplified, with made-up names rather than the platform's own code:
create policy "sub-admins read granted sections only"
on complaints for select
using (
exists (
select 1 from section_grants g
where g.admin_id = auth.uid()
and g.section = 'complaints'
)
);Hiding a button in the app would have stopped nobody who knows how to send a request. A policy in the database stops every app, old or new, the same way.
A ban is a database rule
A society can flag a person or a vehicle, and the database refuses to issue them a pass: a trigger on manual entries, and a check in the function that records an arrival. Because the rule lives there, no app version can skip it, and every grant, revocation and blocklist change is written to the audit log.
The gate has to work offline
Gate phones keep a copy of the blocklist, so the guard is warned even when the connection drops, which at a gate is exactly when it tends to. I also added USB scanner input: a driver holds their phone up to a fixed reader, and the scan runs through the same pipeline as the camera.
Two smaller fixes mattered at the gate too. The list of people inside started a storm of repeated refetches once it reached around 310 people, which I fixed, and I reskinned every gate-keeper screen to the new design system with no change to its behaviour.
If you're building something similar
- Enforce permissions in the database. A hidden button is not access control.
- Make a ban a database rule, so no app version can skip it.
- Keep what the gate needs on the device. The network fails at the worst moment.
- Write every grant and revocation to an audit log, so a question about who changed what has an answer.
Source: Supabase: row-level security (opens in a new tab)
Read next
I build these for startups. AI MVP development