tezvyn:

Role-Based Access Control (RBAC) in Databases

AI-drafted, machine-checkedSource: Wikipedia: Role-based access controlbeginner

RBAC bundles permissions into roles, like 'analyst' or 'admin', instead of assigning them to individuals. This simplifies managing who can read or write data in a database. The footgun is creating too many roles, making it as complex as individual permissions.

WHY IT EXISTS Managing permissions for every single user in a large system is slow, error-prone, and creates security risks. When an employee changes jobs, an administrator might have to manually update dozens of individual access rights. Forgetting one can lead to a data breach or a user being unable to do their job.

THE MENTAL MODEL Think of RBAC like job titles at a company. Instead of creating a unique list of building access permissions for every employee, you define what a 'Sales Rep' or 'Engineer' can access. When you hire a new engineer, you just assign them the 'Engineer' role, and they automatically get all the necessary permissions associated with that title.

HOW IT WORKS RBAC operates on three main components: permissions, roles, and users. A permission is a single, granular action, like SELECT on the customers table. A role is a named collection of these permissions, such as an 'Analyst' role that can SELECT from all sales-related tables. A user is then assigned one or more roles. The system grants access not based on the individual user, but on the permissions granted to the roles they possess.

WHEN TO USE IT RBAC is ideal for systems with a moderate-to-large number of users who fit into well-defined job functions. It shines in enterprise applications, SaaS platforms, and large databases where you have clear groups like administrators, editors, viewers, and support staff. It simplifies auditing and onboarding.

WHEN NOT TO USE IT For very simple systems with only a few users and two permission levels (e.g., 'admin' and 'user'), RBAC can be overkill; direct permission assignment is simpler. It also provides little benefit if every user has a completely unique set of access needs that cannot be grouped into common roles.

ONE CANONICAL EXAMPLE In a PostgreSQL database for an e-commerce site, you might create a customer_support role. This role is granted SELECT permission on the orders and customers tables, but no UPDATE or DELETE permissions. A new support agent is simply granted the customer_support role, instantly giving them the read-only access they need to do their job without risk of modifying critical data.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.