Aller au contenu

Leçon 18 · Security and Privacy

Data Classification and Access Control

Classify data by sensitivity, apply least privilege with role-based and attribute-based access control, use SQL views to limit data, and run access reviews.

You cannot protect everything equally, and you should not try. Classification labels data by sensitivity so that protection matches the harm that exposure, change or loss could cause. Access control then makes sure people and programs reach only what they need.

A simple classification scheme

Many organizations use three or four levels. Names vary:

Level Meaning Example
Public Approved for anyone Published product catalog
Internal For staff; limited harm if exposed Team procedures
Confidential Harm to people or business if exposed Customer contacts, contracts
Restricted Serious harm; strict controls Health records, payment data, passwords

For each level, write the handling rules: who may access, whether encryption is required, where it may be stored, whether it may leave the company and how to dispose of it. A label without rules changes nothing.

Classification also depends on combination. A postal code, birth date and job title can together identify a person even when each seems harmless.

When a dataset mixes levels, treat the whole dataset at its highest level unless you can separate or mask the sensitive columns.

Suggest labels automatically, confirm by people

Automatic scanners can suggest labels from column names and value patterns. They produce both misses and false alarms.

Python Stand-in: suggest classification labels for columns

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The results show the limits. product_name is wrongly flagged as confidential because it contains "name". pwd_hash is missed. note_text could contain anything, including health details typed by staff. A person who knows the data must confirm every label for important datasets.

Principles of access

  • Least privilege: give the minimum access needed for the task.
  • Need to know: access follows a real purpose.
  • Separation of duties: no single person should control a risky process end to end.
  • Default deny: if no rule allows it, it is not allowed.
  • Time limits: temporary access expires automatically.
  • Individual accounts: no shared logins, so actions can be traced.

Access control models

Role-based access control (RBAC) grants permissions to roles, and people get roles. It is easy to explain and review. Attribute-based access control (ABAC) decides using attributes of the user, data and context, such as department, region, classification and purpose. It is more flexible and harder to test. Many systems combine them.

Python Evaluate access with roles and attributes

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Note the default: an unknown role gets no actions at all.

Limit columns with views

A database view can expose only safe columns, and privileges can be granted on the view instead of the table. SQLite has no user accounts, so this example shows the view itself. In server databases you would typically grant SELECT on the view and give those users no access to the base table. How views check permissions differs between databases, so confirm it in your database's documentation and test it.

SQL Expose a reduced view of employee data (SQL)

Press Run (or Ctrl + Enter) to see the result here.

Row-level security features in many databases can further limit which rows a user sees. A report tool's filter alone is not security if users can query the table directly.

Access reviews

Permissions accumulate when people change jobs. Schedule access reviews where owners confirm each person still needs access. Remove access promptly when people leave or move. Log access to sensitive data and look at the logs; unread logs detect nothing.

Do not forget non-human identities: service accounts, integrations and AI agents. Give each its own identity with narrow permissions, rotate secrets, and require human approval before an agent performs risky actions. See AI agents for how such tools work.

Granting broad "temporary" access during an urgent task and never removing it is one of the most common security mistakes. Make temporary access expire automatically.

A worked example: designing access for a team

A fictional insurer's support team needs to answer customer questions. A careless design gives the team the full customer database. A better design lists the tasks first: find a customer, see policy status, update contact details and record a call. From those tasks you derive access:

  • read name, contact details and policy status;
  • edit contact details and add call notes only;
  • no bulk export;
  • no medical notes, which only a claims role may see;
  • every view of a record is logged.

Occasionally a supervisor needs more. Give that as a separate, time-limited permission with a recorded reason, not as a permanent widening of the base role.

Making access requests workable

Tell people how to ask for access, who approves it and how long it takes. Approvers need enough context: what data, which fields, what purpose and for how long. Offer lower-risk alternatives such as aggregated or masked views, which can be approved more easily. If the proper route takes weeks, people will borrow colleagues' exports, and your careful roles will protect very little.

Try it yourself

Pick one dataset, assign a level to each column and then to the whole table. List the roles that need it, the actions each needs and the columns each can do without.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What does least privilege mean?

    It limits damage from mistakes and misuse.
  2. 2. Why should a person confirm automatically suggested labels?

    Name and pattern matching cannot understand context.
  3. 3. A dataset mixes internal and restricted columns that cannot be separated. How should it be treated?

    The highest sensitivity governs unless the columns can be separated or masked.

Summary

  • Classification ties protection to the harm exposure or misuse could cause.
  • Combinations of ordinary fields can identify people.
  • Apply least privilege, default deny and expiring access.
  • RBAC is simple; ABAC is more flexible; views limit columns.
  • Review access for people and service identities.

Next: Protecting Data: Encryption, Masking and Incidents

Votre progression est enregistrée dans ce navigateur. Aucun compte nécessaire.