Roles and Least-Privilege Access
Separate object permissions and understand the limits of a revoke.
database, postgresql, roles, permissions, grants, securitySeparate identities and privileges
PostgreSQL roles can represent login identities or groups of privileges. Grant the minimum needed, distinguish schema access from table access, and review membership, ownership, and inherited or public grants. A role with login capability is not automatically entitled to every object.
SQL illustration
This is a prepared illustration, not a command for a production database.
Assume an administrator has created the fictional training schema,
training.books table, and lesson_reader role in a disposable database.
An authorised object owner or grantor runs:
GRANT USAGE ON SCHEMA training TO lesson_reader;
GRANT SELECT ON TABLE training.books TO lesson_reader;
REVOKE SELECT ON TABLE training.books FROM lesson_reader;
The first grant permits schema lookup; the second grants direct table read
privilege. The revoke removes that direct table grant, but it does not revoke
the schema grant. It also does not necessarily remove effective read access
obtained from PUBLIC, applicable role memberships, ownership, or elevated
privileges. This example does not create credentials or change Intuvo.
See the reasoning
Follow the example one step at a time
Separate schema access, a direct table grant, and other possible grants. This is a prepared teaching demonstration, not live code execution.
Grant schema lookup
lesson_reader
└─ USAGE on training schema
table SELECT: not granted by this stepSchema USAGE permits lookup, but does not itself grant table SELECT.
Review the effective boundary
Connection privileges, schema USAGE, table or column privileges, sequence
privileges, and row-level security are separate concerns. Ownership and
superuser privileges are especially powerful. New objects can have different
default privileges; granting access to existing tables does not automatically
cover future tables. Verify effective access using an appropriate test role,
avoid credentials in examples or logs, and manage permissions through an
authorised deployment process.
Reflect on the concept
Four fixed questions to reinforce the reasoning. Answers are not saved or scored.
