Securing Your Data Hub Application

Secure your Data Hub application using simple configuration. Complete these steps to ensure basic end-to-end security of REST endpoints and data attributes.

Configure the Default Security Profile

Context

Data Hub provides a default Spring security profile. Provide authentication credentials for the roles defined in this profile.

Procedure

  1. Add the following properties to your local.properties file.
    datahub.security.basic.admin.user=<adminuser>
    datahub.security.basic.admin.password=<adminpass>
    datahub.security.basic.read_only.user=<rouser>
    datahub.security.basic.read_only.password=<ropass>
  2. Provide username and password credentials for each of the two roles defined by the default security profile. Use secure passwords that you do not use for any other purpose.

Provide Credentials for Data Hub Adapter

Context

If you are using Data Hub with SAP Commerce Cloud, provide connection credentials for the Data Hub Adapter so it can connect to Data Hub.

Procedure

Add Data Hub Adapter connection credentials to the local.properties file of your SAP Commerce Cloud installation. Data Hub Adapter requires both GET and POST access to all Data Hub REST endpoints. Use the credentials you defined for the admin user to allow this access.
# The username and password for basic authentication of Data Hub adapter with the Data Hub server instance
datahubadapter.datahuboutbound.user=<adminuser>
datahubadapter.datahuboutbound.password=<adminpass>

Create an OAuth Client for Data Hub Adapter

Context

If you are using Data Hub with SAP Commerce Cloud and the Data Hub Adapter, configure a dedicated OAuth client for Data Hub. The configuration is done in the Backoffice Administration Cockpit.

Procedure

  1. Log into the Backoffice Administration Cockpit.
  2. In the Administration perspective, click Start of the navigation pathSystem Next navigation step OAuth Next navigation step OAuth ClientsEnd of the navigation path.
  3. Click the plus sign next to OAuth Client Details.
  4. In the client details window, enter a unique ID in <ClientID> and the client secret. Click Next.

    A new form appears.

  5. Click the plus sign under Authorities, and enter the authority name ROLE_CLIENT.
  6. Click the plus sign under Client Grant Types, and add the following three grant types, exactly as shown:
    • implicit
    • client-credentials
    • password
  7. In a similar way, add the OAuth resource ID hybris, and the Redirect URI https://<yoururl>:9002/auth2_implicit_callback.

    The base of the Redirect URI can change to match your installation, but auth2_implicit_callback must be the same as shown.

  8. Click Next.
  9. Add the OAuth scope basic.
  10. Click Done.

    A banner appears, confirming the creation of the new client.

  11. To see your new client in the list, click Search to refresh the page.
  12. Click the line listing for your client to bring up the client details.
  13. Use the forward and backward arrows, highlighted in the previous image, to switch between your client and the next.

    You should see no change in any of the properties between your client and the eic client, except for the ClientID. The client secret is not shown in cleartext.

  14. Configure Data Hub to use the new client, by adding the following properties to your local.properties file.
    datahub.core.export.service.clientid=demo
    datahub.core.export.service.clientsecret=secret
    Restart Data Hub for the properties to take effect.

Set Up Encryption

Context

Data Hub comes with some built-in encryption capabilities for attributes that you wish to keep secure in the data store. Use this service for such items as passwords and other sensitive data. This is a mandatory step, as target system passwords are encrypted by default.

Procedure

  1. Generate an encryption key.

    Data Hub uses AES/ECB/PKCS5Padding symmetric key encryption with a 128-bit key by default. There are many different ways you can generate an AES key. If you have openSSL installed on your machine, you can generate a 128-bit AES key with a simple terminal command.

    1. Generate a 128-bit AES key using the following terminal command:
      openssl enc -aes-128-ecb -k secret -P -md sha1

      The command produces output that looks something like the following:

      salt=5AFFD797B75FAE1A
      key=ED5D133A8364EA35FC0F4E485C0C0066
    2. Store the key in /opt/datahub/security-dir/.
  2. Specify the path to the file that contains the key by setting the datahub.encryption.key.path property in your local.properties file.
    datahub.encryption.key.path=path/to/encryption-key.txt
  3. Optional: Provide a value for the attribute mask. This value is the text that is returned in place of the actual attribute value, for example, in log output.

    Secured attribute value masking can be configured with the following properties. The default is *******.

    # enable/disable secured attribute value masking
    datahub.secure.data.masking.mode=true
    
    # set the masking value
    datahub.secure.data.masking.value=*******

Define Encrypted Attributes

Context

After you configure encryption and store your key, you can specify which attributes to secure.

Procedure

To secure an attribute, set its secured property to true in your raw.xml and canonical.xml data definitions.
<attribute>
     <name>attributeName</name>
     <model>
          <type>String</type>
          <secured>true</secured>
      </model>
</attribute>

Upon restart, the attribute is encrypted in the Data Hub database, and masked in log files.

Testing Your Secured Configuration

Context

You can test your configuration of the production environment by starting Tomcat and runningData Hub.

Procedure

  1. In a command line, change to the Tomcat directory using the command cd <TOMCAT_HOME>/bin.
  2. Run <TOMCAT_HOME>/bin/startup.sh to launch Tomcat.
  3. In a new command line window, run the following command to start Data Hub.
    curl -G https://localhost:8443/datahub-webapp/v1/version
    The system returns the version number when the configuration is successful.