Tuesday, June 27, 2017

Salesforce Basics - Security Model, Sharing Settings & Sharing Rules

The platform makes it easy for you to implement a security policy of least privilege for all types of users. Effectively, each user should only have the privileges they need to get the job done. Every organization is locked down tightly when you first provision it. These tutorials teach you how to use various features such as users, profiles, permission sets, and roles to progressively open up access so that just the right users have access to just the right data at just the right time.

Here’s a preview of how it’s done.
1. Create profiles and permission sets — Identify the different types of users you need for your application, based on the different functions each type needs to access. Create a base level profile for each type of user such that each profile has only the permissions required for that type of user to perform these functions. Then create permission sets to handle exceptions—situations in which a user may need a few more permissions.
2. Create users — For each person who needs app and database access, create a user, assigning the user to the appropriate profile and permission sets.
3. Set sharing models — For each object, set the organization-wide default record sharing model to determine whether the records that each user owns are public or private.
4. Share private records — Use roles, groups, record sharing rules, and other means to share private records with other users.

Inherent in the design of the platform’s security model is the notion of record ownership, which helps to simplify the implementation of row-level least-privilege data security policies. The creator of a record owns the record after creation and has full access — the owner can read, update, delete, and transfer ownership for the record.
Various data access controls determine whether org users can access records they don’t own. These controls include an object’s sharing model, role hierarchies, groups, and sharing rules.
To begin, each object has a sharing model, also known as an organization-wide default (OWD), which governs the default org-wide access levels users have to each other’s records in the object.
• With an object that uses a private sharing model, the record owner can read and manage a record, assuming that the user’s profile provides object-level access. Other users can work with records they don’t own only by other record sharing means.
• With an object that uses a public read-only sharing model, any user can read all records in the object, assuming that the user’s profile provides the Read permission and field-level access for the object.

• With an object that uses a public read/write sharing model, any user can read and write all records in the object, as permitted by the object- and field-level permissions in each user’s profile

An object can have different sharing requirements based on the user context, so it’s very important to consider this fact when setting its OWD. A good rule of thumb is to set each object’s OWD to be as strict as necessary for the most strict user requirement, and then use sharing rules to open up access, as required.

The information captured on the User Record 
Name, Alias, Email, Username, Delegated Approver, Manager, Title, Company, Department, Division, Address, Time Zone, Locale, Language, Newsletter, Admin Newsletter, Role, Profile, Active, Offline user, Sales Anywhere User, Accessibility Mode, Send Apex Warning Emails, Development Mode, Allow Forecasting, Checkout Enabled, Call Center, Phone, Extension, Fax
Mobile, Email Encoding, Employee Number, Used Space, Last Login

Users cannot be deleted once added. When needed a user needs to be logically deleted ( leaves an org) then transfer all objects ( ownership gets transferred) and set the user to inactive ( by unclicking the 'active' button). This leaves the historic records with that users name, and hence maintains data integrity.

For each and every record there is one and only one record owner. Records can only be assigned to active licensed Salesforce users. When a user is marked inactive, they still own all records assigned to them, but cannot be assigned new records. The terminology “record owner” is reflected through Salesforce. For instance, the “My Opportunities” list view refers to “opportunity records in which I am listed as the record owner”.

Additionally, the role of the record owner is what determines access to that record for the rest of the organization via Sharing Settings. Synchronization applications (Connect for Outlook, Salesforce Offline) will only synchronize records owned by the user by default (two exceptions: sharing groups, if a user owns an account, they will automatically collect all of the contacts regardless of owner).

In practice each user should be responsible for all records owned. For instance, sales rep X owns account ABC Finance. Rep X would be responsible for keeping all address information, contacts, and opportunities up to date.

What's the difference between Sharing Settings and Sharing Rules?
Sharing Settings control the default access for each object across the organization.
Sharing Rules per object can grant access beyond the default Sharing Settings; they cannot restrict access.
Below are different sharing settings available: 
Controlled by Parent
Private
Public Read Only
Public Read/Write
Public Read/Write/Transfer
Public Full Access (campaigns only)

Grant Access Using Hierarchies cannot be disabled for standard objects. When this setting is enabled, the role of the record owner determines visibility throughout the organization. Users in roles higher in the hierarchy will always have full access (view/edit/delete) to all records owned by those lower in hierarchy. If Grant Access Using Hierarchies is not enabled, all roles are treated equally regardless of hierarchy.
Salesforce.com has a flexible sharing model. As the System Administrator, you can define the default sharing model for your organization in order to give users greater access to information. The four sharing model options can be selected separately for Leads, Contacts, Accounts, Assets and Contracts, Opportunities, Cases, and the group Calendar. These options include:
PRIVATE:
This setting for a given object allows users to access only the data they own. No one will be able to view records owned by others.
PUBLIC READ ONLY:
This setting allows users to see, but not change, records in their organization, regardless of who owns those items. Items can also be added by anyone onto related lists with this permission level.
PUBLIC READ - WRITE:
This setting allows all users the ability to view and edit records owned by others. But ownership itself cannot be changed except by the owner.
PUBLIC READ - WRITE - TRANSFER:
This setting on an object allows all users the ability to view, edit, and even change ownership of records owned by others.
To change your Organization Wide Default Security & Access rules:
1. Click on: Setup | Administration Setup | Security Controls | Sharing Rules
2. Click on ""Edit"" for the Organization Wide Defaults
3. Choose the default access level for each object
4. Click "Save"
To change your Organization Wide Default Security & Access rules:
1. Click on: Setup | Administration Setup | Security Controls | Sharing Rules
2. Click on ""Edit"" for the Organization Wide Defaults
3. Choose the default access level for each object
4. Click "Save"
Scope and capabilities of Organization-Wide Defaults 
Organization-wide defaults control the level of access each user has to record they do not own.
Let’s examine an example:

Roles:
C-Level & E-Level Management
Sales Management
Sales Reps
Operations Management
Operations Dispatchers
Customer Service Management
Customer Service Reps

Sharing Settings for Opportunity are set to “Private”. A Sharing Rule exists that grants Operations Dispatchers Read Access to Sales Reps’ opportunities. Here’s how this would play out. We’re looking at access to Sales Reps’ opportunities:

C-Level & E-Level Management Full Access (hierarchy)
Sales Management Full Access (hierarchy)
Sales Reps No Access
Operations Management Read Access (granted by hierarchy)
Operations Dispatcher Read Access (granted by sharing rule)
Customer Service Management No Access
Customer Service Reps No Access

Notice how even sharing rules are affected by Grant Access Using Hierarchies. Note: Group-based sharing rules do not propagate using hierarchies.

Explain how access is granted through the Role Hierarchy
When a user accesses a record they do not own, the following takes place:
1. Security controls- does the user’s profile have access to this object? 
If no, deny access.
2. Is Grant Access Using Hierarchies enabled for this object? 
If No –> Step 3 
If Yes –>
3. Is this user’s role higher in the hierarchy than the role of the record’s owner?
If Yes –> Provide full access
If No –> Grant permissions of any sharing rule for users lower in the hierarchy (see above example)
Grant permissions of any sharing rule specific to my role
Grant permissions of default sharing settings
Grant the highest privileges of all of these steps combined.

Note: sharing rules only control access to the object. Field level accessibility is not
Set up Organization-Wide Defaults
Security Controls –> Sharing Settings

2 comments:

  1. Excellent resource on Salesforce basics, especially the security model! Understanding sharing settings and rules is essential for protecting data, much like how hekateswitch can enhance user experience by providing powerful customization options.

    ReplyDelete

Lightning Inter-Component Communication Patterns

Lightning Inter-Component Communication Patterns If you’re comfortable with how a Lightning Component works and want to build producti...