Most access control starts with a question: who are you? The system authenticates a user, looks up their permissions, and decides what they may see.
There is a class of problem where that question cannot be asked.
A paramedic walks into an unfamiliar house. Someone is on the floor, unresponsive. The information that matters, what they take, what they are allergic to, what happened the last time this occurred, exists somewhere. In a care provider’s system. In a GP record. In a folder in a drawer. The paramedic has no account on any of those systems, no time to request one, and no way to ask the person on the floor for consent.
The same shape appears elsewhere. A fire crew needs a building’s hazard register. A substitute carer arrives at a house they have never visited. In each case the person who needs the data is legitimate, unknown to the system, and operating under time pressure.
This article describes a design for that problem: a physical trigger in the environment, no login at the point of access, and the controls a regulated organisation actually needs, still enforced.
The constraint that shapes everything
No login means there is no user identity at the moment of access.
Everything follows from that. You cannot check a role, because there is no account to carry one. You cannot ask the subject, because they may be unconscious. You cannot defer to an administrator, because nobody is awake.
So the design question changes. Instead of “who is this person and what may they see”, it becomes:
Given that an unidentified person is holding a physical object that implies they are physically present at a specific location, what is the minimum they should see, for how long, and how do we prove afterwards what happened?
Three properties drop out of that. Access is scoped rather than general. It is time limited rather than permanent. And it is audited, always, because the audit trail is the only accountability mechanism left once identity is gone.
Why the obvious implementation fails
The obvious implementation is a QR code or NFC tag containing a URL with an identifier in it. Scan, fetch, display.
This fails in four ways, and they are worth spelling out because none of them is obvious until you look.
The identifier becomes a permanent bearer credential. Anyone who photographs the sticker, or finds the URL in a browser history, a screenshot or a shared chat, has indefinite access. There is no expiry because there is no session.
It is enumerable unless you are careful. Sequential or structured identifiers can be walked. Even random identifiers leak through referrer headers, server logs, analytics and link previews in messaging apps.
There is no revocation. A sticker in the world cannot be recalled. If the identifier is the credential, losing control of the identifier means losing control of the record permanently.
There is no audit worth the name. A web request log tells you that an identifier was fetched. It does not tell you that an access occurred which a Data Protection Officer could later defend.
The fix for all four is the same move. The physical object must not carry the credential. It carries a pointer, and the server decides, every time.
Three actors, not three roles
Rather than one notion of “user”, the design separates three kinds of participant, each with a different relationship to the record.
The subject. The person the record is about. They, or someone with authority for them, control what exists and what is shareable. They are usually not present at the moment of access, which is the entire point.
The organisation. The care provider, the employer, the operator. They hold the regulatory obligation, they manage records at scale, and their staff have accounts with ordinary authenticated roles. Their access is broad but identified.
The responder. Unknown, unauthenticated, physically present, under time pressure. Narrow access, short lived, fully logged.
Modelling these as three different things rather than three permission levels on one user object matters, because they differ not in how much they can see but in how they are authorised at all. The subject is authorised by ownership. The organisation by an authenticated account. The responder by physical possession of an object, plus a decision the server makes in that moment.
Collapse them into one user table with a role column and you will spend the rest of the project writing exceptions.
Server-mediated access: the pointer, not the key
The physical tag carries an opaque reference. It is not a credential and it grants nothing on its own.
When it is presented, the server makes a decision. It checks that the reference resolves to something currently active. It checks that the record is in a state where emergency access is permitted. It checks that the request does not form part of a pattern that looks more like probing than use. Only then does it issue a short lived, scoped token and return the specific subset of data an emergency responder needs.
Four properties follow, and each one answers one of the failures above.
Expiry comes free. The token has a short lifetime. The reference on the sticker is not a credential, so photographing the sticker gains an attacker nothing they could not get by standing at the door.
Revocation becomes possible. Because the server decides on every presentation, a reference can be deactivated centrally. The sticker in the world stops working without anyone retrieving it.
Scope is enforced server side. The responder view is a deliberately narrow projection of the record, decided by the server, never filtered in a client an attacker controls.
The access event becomes a first class object. Because a decision happens on the server, there is a natural place to record that a decision happened, what was shown, and under what conditions.
Enforcing it in the database, not the application
The application layer is the part an attacker reaches first. It is also the part that changes most often, gets refactored under deadline, and accumulates endpoints that someone forgot to guard.
So the rule is enforced one layer down, in the database, using row level security.
Row level security in PostgreSQL attaches policies to tables. Every query, whatever issued it, is filtered by those policies. A developer who adds a new endpoint and forgets the authorisation check does not thereby create a data leak, because the policy still applies. The guarantee stops depending on every future developer remembering.
For this design that means policies expressed in terms of the three actors. A subject sees their own record. An organisation sees records belonging to it. A responder session sees the narrow emergency projection of exactly the record their token refers to, and nothing else.
The benefits are worth stating concretely.
Defence in depth that actually holds. A bug in the API does not become a breach, because the database still refuses.
New endpoints inherit protection. Policies cover tables, so anything touching the table is covered.
The policy is readable. A rule written in SQL next to the table is auditable in a way that authorisation logic scattered across a codebase is not. When somebody asks “who can see this”, there is one place to look.
The costs are real too. Policies add query complexity and can hurt performance if written carelessly. Debugging is harder, because a query returning nothing may be correct policy behaviour rather than a bug. And policies are schema objects, which means they need versioning, migration and testing like anything else.
Adding row level security to a system that is already live
Designing this from scratch is the easy version. Introducing it to a system already carrying real data and real users is where it gets interesting, and it is worth describing because most people arrive at this point rather than starting there.
The instinct is to write the policies, enable them and deploy. Do not. Enabling row level security on a populated table changes what every existing query returns, including queries in parts of the system you had not thought about. A policy that is slightly too strict does not throw an error. It returns an empty set, silently, and the first you hear of it is a user saying something has disappeared.
What works better is sequencing. Introduce one table at a time, not the schema at once. For each one, write the policy, enable it, and verify that every existing access path still behaves before moving on. Keep every step independently reversible, so a problem means rolling back one change rather than unwinding a release.
That is slower and considerably less satisfying than a single migration. It is also the difference between a security improvement and an outage, and on a system with live users there is no version of this where downtime is acceptable.
The general principle: a security change that nobody can verify incrementally is a security change nobody should deploy at once.
Audit as a design requirement, not a feature
When identity is absent, the audit trail is the only accountability mechanism remaining. That makes it structural rather than optional.
What gets recorded is every access decision, not every HTTP request: which reference was presented, what the server decided, what projection was returned, when, and under what conditions. It needs to be append only in practice, because an audit log that can be quietly edited proves nothing.
The test to design against is not technical. It is this: six months later, a regulator asks what was disclosed, to whom, and under what authority. Can you answer, from the system, without reconstructing it from memory?
If the answer is no, everything above is decoration.
Data protection when consent cannot be asked
Any organisation operating this pattern in the UK or EU has to answer several questions before writing code.
Lawful basis. Consent is not available at the moment of access, because the subject may be unconscious. The design has to rest on a basis established in advance, when the record is created, and what was agreed then constrains what can be shown later.
Data minimisation. The responder projection should contain what changes an emergency decision and nothing else. The discipline is justifying every field, rather than including everything because it might help.
Purpose limitation. Data gathered for emergency access should not quietly become available for other purposes because it is convenient.
Retention. The record, the access log and the references themselves each need a defined lifecycle, including what happens when a subject leaves the organisation or withdraws.
None of these are details to add afterwards. Each one constrains the schema.
What is still unsolved
Being honest about the limits is more useful than claiming the pattern is finished.
Physical possession is a weak authorisation signal. It is the best available when nothing else exists, and it is genuinely weak. Someone who should not be in the building is authorised by the same mechanism as a paramedic.
There is no way to confirm the responder is who they imply. Verifying a professional credential at the point of access would be better, and is not practical in the time available.
Offline is hard. Server mediated access needs connectivity at exactly the moment connectivity is least reliable.
The time limit is a guess. Too short and the token expires mid incident. Too long and the window is wider than it needs to be. There is no principled way to choose the number, only a defensible one.
Closing
Removing authentication does not have to mean removing control. It means moving the control somewhere else: from identity to possession plus a server side decision, from the application layer to the database, from permission checks to an audit trail that can answer a regulator.
Most access control design assumes the user can identify themselves. A surprising number of real situations, emergency response among them, break that assumption. This is one way to work without it.