Sub topic 10
Controlling Access with Profiles and Permission Sets
This chapter assumes you can administer users, profiles, and permission sets in Setup, and that you know what a connected app's OAuth settings and policies are. It covers how to decide which users may use an app and what happens when a user is not allowed.
Why a policy alone is not enough
An OAuth flow proves that a user signed in and approved an app. It does not decide whether that user should be allowed to use the app. That decision belongs to the Permitted Users policy on the connected app. The policy has two options that matter here:
- All users may self-authorize. Any user in the org can approve the app. No admin setup is needed.
- Admin approved users are pre-authorized. Only users whose profile or permission set is assigned to the app can get a token. Everyone else is refused.
Use the second option for anything that touches sensitive data. The first option suits low-risk apps where each user decides for themselves.
Assigning profiles and permission sets
When you choose admin-approved users, you must also say who is approved. Open the app's Manage page and use the Profiles and Permission Sets related lists. Any user who has a listed profile, or has a listed permission set assigned, is pre-authorized.
Prefer permission sets over profiles. A permission set can be assigned to a single user or a group, and you can remove it without changing the profile that many other users share.
What the user experiences
The two policy settings behave differently at sign-in, as the table shows.
| Permitted Users setting | User is approved | User is not approved |
|---|---|---|
| All users may self-authorize | Sees the approval screen once, then gets a token | Same as approved. Everyone can authorize |
| Admin approved users are pre-authorized | Gets a token with no approval screen | Receives an error and no token |
How the check happens
Server-to-server flows
Access control still applies to flows with no interactive login. The JWT bearer flow runs as the user named in the sub claim. With admin-approved users, that user must hold an assigned profile or permission set, or the token request fails. The client credentials flow runs as the run-as user set in the app's policies, so that user's permissions limit what the token can do.
A good pattern is a dedicated integration user. Give that user a permission set that is assigned to the app and that grants only the object and field access the integration needs. Then a leaked token cannot exceed those permissions.
Common mistakes
- Leaving the policy on self-authorize for an app that reads sensitive records.
- Assigning a broad profile such as System Administrator to an integration user.
- Adding users to the permission set but forgetting to assign the permission set to the app.
- Changing the policy after users have authorized, and expecting existing tokens to stop working. Revoke their sessions as well.
Exercise
A JWT bearer integration fails with an error after you switch the app to "Admin approved users are pre-authorized". The integration user's profile is not assigned to the app. What is the least-privilege fix?
Show answer
Create a permission set that grants only the access the integration needs, assign it to the integration user, and add that permission set to the connected app's Permission Sets list. Do not assign a broad profile to the app.