The query finished running, but the data wasn’t safe. Rows bled into places they shouldn’t. You needed identity-aware enforcement at the database layer, not a generic permission check upstream. That’s where OpenID Connect (OIDC) and Row-Level Security meet.
OpenID Connect is the protocol that verifies who’s at the door. Row-Level Security (RLS) decides what they can see once inside. Together, they provide user-scoped data control directly in the datastore, eliminating fragile filtering in API code.
With OIDC, authentication is delegated to a trusted provider. The user logs in, the provider issues a JSON Web Token (JWT). This token contains claims — user ID, roles, groups. RLS policies in the database can inspect these claims to decide access, cutting application complexity and reducing attack surface.
A common pattern is to parse the OIDC sub claim (the subject identifier) into a session variable on connect. In Postgres, for example, you can set: