Sub topic 10
Verifying what the integration user can do
This chapter covers how to check the effective permissions of the integration user. It assumes you know basic Salesforce administration (users, profiles, objects, fields), SOQL, and the OAuth 2.0 JWT bearer flow. You also need a sandbox or Developer Edition org where you have admin rights.
Building a permission set is only half the job. Salesforce combines the profile, every assigned permission set, field-level security, and the sharing model to decide what a user can do. A mistake in any one layer can grant more than you intended, or block something the integration needs. Verification means checking the result from two directions:
- Inspect the configuration to see what is granted.
- Run the integration user's own session to see what actually works and what is denied.
Why configuration review is not enough
Reading a permission set tells you what that permission set grants. It does not tell you what the user ends up with. Permissions in Salesforce are additive. If the user holds three permission sets and the profile, the effective access is the union of all of them.
Several things can add access that you did not see in the permission set you just built:
- The profile, which also owns a hidden permission set of its own.
- Other permission sets assigned earlier, or through a permission set group.
- Sharing rules, role hierarchy, and organization-wide defaults, which affect which records are visible.
- User permissions such as View All Data or Modify All Data, which override object and record checks.
The verification workflow therefore has four steps.
Step 1: List every assignment
Start by listing everything assigned to the user. The query below returns permission sets and also the permission set that Salesforce creates for each profile.
SELECT PermissionSet.Name, PermissionSet.Label, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE AssigneeId = '005XXXXXXXXXXXXXXX'Replace the placeholder with the Id of your integration user. Read the result like this:
| Row type | How to recognize it | What to check |
|---|---|---|
| Profile-owned permission set | `IsOwnedByProfile` is true | The profile should be minimal, so this row grants little. |
| Your integration permission set | Name matches the one you built | This is the main source of access. |
| Anything else | Any other name | Remove it, or document why the integration needs it. |
If you see a permission set you do not recognize, stop and find out where it came from. A common cause is a permission set group assigned to a whole team that the integration user was copied into.
Step 2: Inspect object permissions
Next, look at what each permission set grants on objects. This query shows the flags for one permission set.
SELECT SobjectType, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords
FROM ObjectPermissions
WHERE Parent.Name = 'Integration_Account_Read'For a read-only Account integration, you expect one row for Account with only PermissionsRead set to true. Check these flags in particular:
PermissionsDelete: should be false unless the integration deletes records.PermissionsViewAllRecords: bypasses sharing for that object.PermissionsModifyAllRecords: grants edit and delete on every record of that object, regardless of sharing.
You can run the same query against FieldPermissions to check field-level security. Filter on Parent.Name and SobjectType and look at PermissionsRead and PermissionsEdit.
Also check the system-wide user permissions, because they sit outside the object tables. In Setup, open the permission set and look at System Permissions. The ones to look for are View All Data, Modify All Data, and any administrative permission the integration does not need. ApiEnabled is required for API access and is the one system permission you expect to see.
The metadata view
You can also review the permission set as metadata, which is easier to compare across sandbox and production and to keep in version control. The example below is the expected shape for the read-only Account integration.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Read-only access to Account for the integration user</description>
<fieldPermissions>
<editable>false</editable>
<field>Account.Industry</field>
<readable>true</readable>
</fieldPermissions>
<hasActivationRequired>false</hasActivationRequired>
<label>Integration Account Read</label>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Account</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<userPermissions>
<enabled>true</enabled>
<name>ApiEnabled</name>
</userPermissions>
</PermissionSet>Notice what is absent: no ViewAllData, no ModifyAllData, and no other objects. If a retrieved copy of the permission set has extra entries, someone changed it after you built it.
Step 3: Test with the integration user's own session
Configuration review shows intent. A live test shows behavior. Log in as the integration user with the JWT bearer flow, then run a query that should succeed.
sf org login jwt \
--client-id "$SF_CLIENT_ID" \
--jwt-key-file server.key \
--username [email protected] \
--instance-url https://test.salesforce.com \
--alias integration-sandbox
sf data query \
--target-org integration-sandbox \
--query "SELECT Id, Name, Industry FROM Account LIMIT 5"The --instance-url https://test.salesforce.com value is for a sandbox. For a Developer Edition or production org, use https://login.salesforce.com instead.
The test must run as the integration user, not as your admin account. If you query with your own admin login, the result tells you nothing about the integration user. Confirm which user a session belongs to before you trust the output.
sf org display --target-org integration-sandboxCheck that the username in the output is the integration user.
What a correct result looks like
For this example, the query returns rows with the three fields. The number of rows depends on sharing. If the organization-wide default for Account is Private and the integration user owns no records and has no sharing rule, the query returns zero rows without an error. Zero rows is a sharing result, not a permission set failure. Distinguish the two:
| Symptom | Likely layer |
|---|---|
| `INSUFFICIENT_ACCESS` or "sObject type is not supported" | Object permission is missing, or the object is not visible to the user's license. |
| `No such column` on a field | Field-level security does not grant read on that field. |
| Query succeeds with zero rows | Sharing does not expose any records to the user. |
| Login fails with `invalid_grant` | OAuth setup: the user is not pre-authorized, or the certificate or username is wrong. |
Step 4: Test denial
A least-privilege check is incomplete until you confirm that forbidden actions fail. Run the same command against things the user should not reach. Each of the following should fail:
- Query an object the integration was never granted, such as Contact.
- Query a field you did not grant, such as
Account.AnnualRevenue. - Try to create an Account.
- Try to delete an Account.
sf data query \
--target-org integration-sandbox \
--query "SELECT Id, LastName FROM Contact LIMIT 1"
sf data create record \
--target-org integration-sandbox \
--sobject Account \
--values "Name='Denial Test'"Both commands should return an error. If the create succeeds, the user has more access than the requirements list allows, so go back to Step 1 and find the extra grant. If you created a test record by accident, delete it with an admin account.
Step 5: Check how the user has been logging in
Verification also covers the authentication side. Review recent logins to confirm that they come from the places you expect.
SELECT LoginTime, SourceIp, LoginType, Status, Application
FROM LoginHistory
WHERE UserId = '005XXXXXXXXXXXXXXX'
ORDER BY LoginTime DESC
LIMIT 20Look for these:
SourceIpvalues outside the ranges you allowed.- An
Applicationthat is not your connected app. - Failed rows in
Status, which can show a misconfigured integration or an attempted misuse. - A
LoginTypethat suggests an interactive login, such as a UI login, for a user that should only connect through the API.
Common verification mistakes
- Testing as an admin. The admin account passes every test, so the test proves nothing about the integration user.
- Reading only the new permission set. Access can come from the profile or another assignment, so Step 1 comes first.
- Treating zero rows as success. Zero rows might mean sharing hides everything, which is a different problem from a correct, narrow grant.
- Skipping denial tests. Testing only the allowed paths cannot find over-privilege.
- Verifying once. The result holds only until someone changes an assignment or permission set. Repeat the checks after every change.
Exercises
Exercise
The integration user's query of Account returns zero rows and no error. The permission set grants Read on Account, and field-level security allows the queried fields. Which layer should you inspect next, and why?
Show answer
Inspect the sharing model. A missing object or field permission produces an error, not an empty result. Zero rows with no error means the user may read Account in general but cannot see any individual records. Check the organization-wide default for Account, the sharing rules, and record ownership. Do not fix this by adding View All Records unless the requirements list says the integration needs every record.
Exercise
You run the allowed query and it works, but you ran it with your own admin login. What is wrong with this test, and how do you correct it?
Show answer
An admin session has broad access, so a successful query does not show what the integration user can do. Log in as the integration user with the JWT bearer flow, confirm the username with sf org display, and rerun both the allowed and the denied queries from that session.
Exercise
A PermissionSetAssignment query for the integration user returns three rows: the profile-owned permission set, Integration Account Read, and a permission set called SalesTeamBase. What do you do?
Show answer
SalesTeamBase is not part of the requirements list. Find out why it is assigned and what it grants by running the ObjectPermissions query on it. If the integration does not need it, remove the assignment. Then repeat the denial tests to confirm that access has narrowed.