Authorization

To protect your SAP Commerce Cloud instance and data, you need to make sure that only authorized parties have access.

Managing and Checking Access Rights

By using the permissions services framework you can manage and check the access rights for users and user groups. You can assign, modify or remove permissions related to your users like employees and customers. You can also manage and check access rights assigned for the user groups.

The permissions services described in Managing and Checking Access Rights can be used to implement access rights system on the Platform. The framework has separate services for managing the access rights and checking what kind of access rights are assigned.

Creating Permissions

Take into account that, once a permission is defined and used, there are no means to delete it. Such an operation would require checking the entire database to ensure that the permission is not used anywhere. This could also lead to a hole in the security system. Since permissions are only distinguished by name, removing a permission and then adding another one with the same name makes the existing security audit logs useless. Therefore plan your access rights system upfront and validate it before implementation.

Checking Permissions

The permission checking service provides the answer about assigned permissions. These questions can be specified for:

  • Given permission
  • Principal
  • Object
  • Item
    • Item type
    • Attribute descriptor

The answer is calculated out of the existing permission assignments and provides information about actual permission assignments (i.e. the permissions that were directly assigned). Permissions assigned indirectly are calculated by permission checking rules, which take into account permission inheritance within principal group hierarchy and inheritance within type and attribute descriptor hierarchy.

actual permission assignments + permission checking rules = effective permission assignments

Effective permission assignments might not physically exist in the system, but are the effect of using checking rules. For example, if there is an actual permission assignment to a user group, then every member of the group has that permission effectively assigned. This happens because user group permissions are inherited by users who belong to the group.

Permission Checking Rules

Permission checking rules prioritize different kind of permission assignments. For example, global assignments have the lowest priority.

The result of checking permission assignment can be one of the following constants defined by PermissionCheckValue:

  • ALLOWED: Permission is granted for a principal
  • DENIED: Permission is explicitly denied for a principal
  • NOT_DEFINED: No actual permission assignment was found for the given permission checking operation
  • CONFLICTING: Situation when there are both DENIED and ALLOWED equal-priority assignments for a principal

PermissionCheckValue should be mapped to a single boolean yes or no answer. Default mapping can be changed by using different PermissionCheckValueMappingStrategy. By default this strategy assumes that:

  • Only ALLOWED maps to true
  • Other values map to false

Permissions are not automatically enforced. This means that you have to assign them properly using PermissionCheckingService and then act accordingly in order to have a permission-based security.

Permissions Scope

Generally, you can assign permissions to types, items, and attributes. Additionally you can assign global permissions to the users.

  • Global Permissions: Related to the user or user group and is meant to have the lowest priority. It means that the global permissions assigned to the particular user/group can be overwritten by assigning permissions to the specific item, type or attribute. The global permissions apply in case there are no other permissions defined. Global permission assignments should be used as a fall-back or default assignment.

  • Type Permissions: Apply to the entire type's data. Access rights to the type can be granted in several stages, for example Read, Change, Create, and Delete. When you assign permissions to the types. Every item of that type will inherit this permission assignments. This works across type hierarchy.

  • Item Permissions: Can be assigned to the particular instance of the previously defined type. Simply speaking, if you can create many items of some type, this could allow you to override type-related access rights and assign permissions for a certain user to the particular concrete item.

  • Attribute Permissions: Can be granted or denied explicitly for the individual attributes holding the informational content of a type or an item. This can be used for even more refined access control. Attribute-wide access rights can be granted in a few stages, for example: Read and Change. You should use the attribute descriptor assignments for fine-grained control of the attribute values.

Permission assignments can be either positive (allowed or granted) or negative (disallowed or denied).

Limitations of Permissions

  • Effective permission assignments are calculated, and there is no easy way for the database server to perform such calculations when retrieving item rows from the database. This also means that permissions cannot be used for filtering rows in the data access layer.
  • Permission assignments are currently not represented by models, you cannot directly import them using the ImpEx scripts. The only way is to use PermissionManagementService from ImpEx using scripting.

Users in the SAP Commerce Cloud Platform

The Principal type is the main abstract class for user and usergroup types.

The following diagram gives an overview of Principal types.

The uid must be globally unique for all types that descend from the Principal type. A user and a group cannot have the same identifier, same applies for an employee and a customer.

System Accounts

There are three special system user items that are essential to the platform and cannot be modified or deleted.

These are:

  • employee: admin
  • customer: anonymous
  • usergroup: admingroup

Both the anonymous and admin users are protected from removal and against renaming. You can add other users to the admingroup. Those users would have the same rights as the admin user.

There is no way to limit the access rights of the admin user. Be careful when using the admin user, because the Rule Framework is evaluated for all users except the admin user. The administrator has full access rights to everything within the system.

Information about users may differ in the Backoffice Application. To know more, see Business Roles in Backoffice

Users

You should use the user type to create more specific types that define accounts for your employees and customers. It is possible to create an item of a user type, but it should be avoided. Items of user type will have another permission hierarchy than items with type employee or customer and there will be no possibility to distinguish the role played by the items.

customer Type

Extended from the user type, the customer type is designed to be used for customers who visit your front-end application. Depending on your business context, customers can create their own accounts and have full or limited access to all their data.

Crucial customer data for ordering process, like address or payment information, are kept safe by being duplicated to the Order item. When a customer makes an order, the delivery address and payment information are copied to the Order item and are stored separately to secure that the shipment arrives at the correct address and is correctly paid. Even, if a customer changes payment information or delivery address after the order was made, the shipment is paid and delivered according to the information stored with the Order item.

Customers are not allowed to manage SAP Commerce Cloud. It is technically possible to grant a customer account access to the SAP Commerce Cloud management tools. However this is not recommended and should not be allowed.

employee Type

Extended from the user type, the employee user can have access to the back office management tools and can perform several management actions as defined by the system of permissions and other regulations.

The employee user is a representation of a member of your company. This account is used to, depending on assigned permissions, manage objects in SAP Commerce Cloud.

A special kind of employee user is the admin user. This account cannot be removed, renamed, or restricted. Access rights framework checks if the user is admin, if yes, then no evaluation rule is checked to defined permissions for admin. User admin has access to everything within SAP Commerce Cloud. The admin user is special in that extent that it is member of the admingroup user group. This groups has no factory default limitations, nor restrictions.

You can create other employee users later as the need arises, manually or by using ImpEx scripts. By installing new cockpits, you also receive some factory default users that come together with particular cockpit extensions. There are several factory default employee accounts that come with the SAP Commerce Cloud system.

Restrictions

Restrictions are rules obeyed by FlexibleSearch which allow you to limit search results depending on which type is searched and which user is currently logged in.

A restriction always applies to a specified type and a specified User or UserGroup. If the type has subtypes, then the subtypes are affected by the restriction as well. If the restriction applies to a UserGroup, then it affects all members of that UserGroup, including other UserGroups (whose members are affected by the restriction as well).

Restrictions work on FlexibleSearch queries only and do not affect the following use cases:

  • External search engines

    Search results supplied by third-party search engines are not affected by restrictions. To get third-party search engine search results affected by restrictions, you will need to filter these search results by running a FlexibleSearch statement over them.

  • Item.getProperty(), LocalizableItem.getLocalizedProperty() fetches item references directly via PK – any stored item will be returned no matter if it would have been filtered by a currently active restriction

Restrictions and admin users

By convention, restrictions do not apply to admin users (that is, users who are members of the admingroup user group). This means that a session assigned to a member of the admingroup user group is not affected by restrictions. This setting is in effect as long as the session is assigned to an admin user and applies to all restrictions.

Restrictions for cronjobs

Restrictions can be used for cronjobs. The effect is that you can limit the scope of items that the job can access. For example, you can explicitly exclude certain catalog versions from the scope of the SyncItemJob, with the effect that the SyncItemJob ignores these catalog versions.

The restriction attribute of the Job type can hold any number of JobSearchRestrictionModel objects. Each object holds mainly the type, on which the restriction takes effect and the restricting query.

To allow access to attributes of the Job and CronJob, the SessionContext used within the Job holds a reference to the Job and the CronJob via session.currentJob and session.currentCronJob, respectively. For example, to ensure that a Job only uses the set catalog version, you could create a restriction using the following query:

{code} IS NULL AND {catalogversion}=?session.currentJob.targetversion

Disabling Anonymous Login in Core

By default, the anonymous login cannot be used to log into the platform.

In the platform's advanced.properties by default there is:

#################### ANONYMOUS LOGIN SETTINGS #########################
# Fixedly disables the ability to log in using the 'anonymous' account.
# If you really need require using that account for login you must change
# this setting to 'false'!
#######################################################################
login.anonymous.always.disabled=true

This property ensures that the User.isLoginDisabled will always return true for the anonymous customer and User.checkPassword will always return false for the anonymous customer. Make sure that this property has not been overridden in the local.properties or project properties files.

Secure Access to the Cockpits

Make sure that only Employees in the Employeegroup can access the cockpits and Customers in the customergroup can access the storefront.

The cockpit spring configuration enforces this through the defaultCorePreAuthenticationChecks bean, defined in cockpit-spring-security.xml

<alias name="defaultCorePreAuthenticationChecks" alias="corePreAuthenticationChecks"/>
<bean id="defaultCorePreAuthenticationChecks" class="de.hybris.platform.spring.security.RejectUserPreAuthenticationChecks">
    <property name="allowedUserGroups">
        <list>
            <value>Admingroup</value>
            <value>Employeegroup</value>
        </list>
    </property>
    <property name="allowedUserTypes">
        <list>
            <value>Employee</value>
        </list>
    </property>
</bean>

Secure Access to Media

All media files, that can contain any personal data should be placed in secured media folders.

Placing media in a secured media folder doesn't make it secure without the proper configuration.

The persisted data of a media will be stored in an unprotected media folder when using the default settings.

Permissions work on several levels in the platform. Having read access to a media is granted if:

  • a principal has a positive read permission on it (what you have set up), or
  • a principal has a positive read permission on the Media type (which is mandatory to view medias in general in Backoffice), or
  • a principal has a global positive read permission (without type)

The secure media folder does work correctly if permissions are set up correctly.

For scenarios where only a specific principal should have access to specific media, permissions granted on the type level have to be overwritten by:

  • Assigning positive read permissions for the principal who should see it
  • Assigning positive read permissions for all the principal groups which have positive read permissions on Media types but should not have access to specific media.