Sub topic 11
Designing access with least privilege
This chapter assumes you know what a user licence, a profile and a permission set are, and that you can open Setup and assign permission sets to a user. It covers how to combine them so each person gets only the access their job needs.
What least privilege means in Salesforce
Least privilege means a user gets the minimum access needed to do their work, and nothing more. In Salesforce this limits the damage from mistakes, compromised accounts and over-broad data exports. It also makes audits simpler, because each grant has a stated reason.
Three layers decide what a user can do:
- The user licence sets the ceiling. A profile or permission set cannot grant something the licence does not allow.
- The profile sets the baseline that every user with that profile shares.
- Permission sets add access on top of the baseline.
Keep the baseline small
Permission sets can only add access. A profile can grant access and, because it is the base, it is also the place where excess permissions get shared by everyone assigned to it. If the baseline is broad, you cannot take that access away from one user with a permission set.
So make the profile as narrow as the least-privileged person who uses it. Then add what each role needs.
- Clone a minimal profile for each licence type that you use. Do not edit the standard profiles to make them narrower.
- Leave object permissions such as Delete, View All and Modify All off the profile unless every user needs them.
- Treat "View All Data" and "Modify All Data" as exceptional. Put them in a permission set that you assign to named people.
Build permission sets around tasks
Design each permission set around one job function or task, not around one person. Name it for what it enables.
| Weak design | Better design |
|---|---|
| One permission set called "Sales Extras" with unrelated grants | "Quote Approver", "Report Builder" and "Export Data" as separate sets |
| A copy of the admin profile for one manager | A standard profile plus "Manage Team Dashboards" |
| Granting access directly to each user's profile | Permission set groups for each job role |
When several sets always go together, bundle them into a permission set group. Assign the group to the user, and update the group when the role changes. This gives you one assignment per person and one place to review.
Separate access from visibility
Object and field permissions say what a user can do with a type of record. Roles, sharing rules and organisation-wide defaults decide which records the user can see. Review both. A user with narrow object permissions can still see many records through the role hierarchy, and a user with broad permissions sees little if the sharing model is private.
Review and remove
Access tends to grow and rarely shrinks. Build a routine:
- Review permission set assignments when someone changes team.
- Remove assignments you no longer need. Removing a permission set takes effect immediately.
- Deactivate users who have left, which also frees the licence.
You can list who holds a permission set with SOQL.
SELECT Assignee.Name, Assignee.Username, PermissionSet.Label
FROM PermissionSetAssignment
WHERE PermissionSet.Name = 'Your_Permission_Set_API_Name'
ORDER BY Assignee.NameReplace the API name with a real one from your org. Each row is one user who holds that set, so you can check whether each assignment is still justified.
Common mistakes
- Cloning a broad profile for each new request, which spreads excess access across many profiles.
- Granting "Modify All Data" to fix a single permission error, instead of finding the missing object or field permission.
- Assigning permission sets one user at a time with no group, so no one can tell what a role should have.
Exercise
A new support agent needs to edit cases, and their manager also wants them to export reports. The profile you plan to use already allows exporting for all users. What should you change, and why?
Show answer
Remove the export permission from the profile, so that it is not part of the baseline for everyone. Create a separate permission set, such as "Export Reports", and assign it only to the agent (or to those who need it). Then the baseline stays minimal and the extra access is explicit, reviewable and easy to remove. Case editing can go in a task-based permission set or the profile, depending on whether all users of that profile need it.