Application Security

Data Hub implements HTTP/SSL to encrypt inbound and outbound data. In addition, Data Hub also uses basic authentication configured with Spring Security to secure its RESTful endpoints. Authentication is enabled by default, and Data Hub returns an HTTP status code 401 Unauthorized when secured REST endpoints are accessed without a valid authentication header.

Basic authentication requires credentials (username and password) to be included in all requests to Data Hub REST endpoints.

In the following codeblock, an example of a typical client-side HTTP request header appears that includes the Authorization field. The username and password combine into a string separated by a colon and then base64 encoded.
POST / HTTPS/1.1
Host: example.org
Content-type: application/json
Authorization: Basic YWRtaW46bmltZGE=

Data Hub Users

The following user property names are available in Data Hub and have access to the roles listed in the table.
User Roles
admin

{datahub.security.basic.admin.user}

ROLE_DATAHUB_ADMIN

ROLE_DATAHUB_RO

ROLE_DATAHUB_CONTENT_OWNER

ROLE_DATAHUB_INBOUND

developer

{datahub.security.basic.developer.user}

ROLE_DATAHUB_ADMIN

ROLE_DATAHUB_RO

ROLE_DATAHUB_INBOUND

datahub

{datahub.security.basic.read_only.user}

ROLE_DATAHUB_RO
owner

{datahub.security.basic.content_owner.user}

ROLE_DATAHUB_RO

ROLE_DATAHUB_CONTENT_OWNER

inbound

{datahub.security.basic.inbound.user}

ROLE_DATAHUB_INBOUND

Default Spring Security Configuration

The default Spring Security configuration shipped with Data Hub defines four roles:

  • <ROLE_DATAHUB_ADMIN> - provides unrestricted access to all Data Hub REST API resources
  • <ROLE_DATAHUB_RO> - allows only restricted access to GET methods for all Data Hub REST API resources
  • <ROLE_DATAHUB_INBOUND> - only allows the user to load data into Data Hub
  • <ROLE_DATAHUB_CONTENT_OWNER> - allows the user to view attributes in a data item. This role can only authenticate; it cannot perform any actions.
Role Access by Method

Role

Accessible Methods

All roles

GET

ROLE_DATAHUB_INBOUND

POST, PUT

ROLE_DATAHUB_ADMIN

GET, DELETE

ROLE_DATAHUB_RO

GET
To provide authentication credentials for the two roles defined for the default security profile, add the following 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>
datahub.security.basic.inbound.user=<inbound>
datahub.security.basic.inbound.password=<dnuobni>
datahub.security.basic.content_owner.user
datahub.security.basic.read_only.user

For a production environment, SAP recommends that you provide a secure username and password for each role. The properties file contains clear text passwords, so protect them in a production environment.

When using Tomcat, you may want to further secure your environment using tomcat-users.xml and implement a security context for these roles in the Tomcat Manager. A security context provides additional consistency. To read about configuring manager application access and how to set those roles, see https://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html#Configuring_Manager_Application_AccessInformation published on non-SAP site.

Overriding the Default Configuration

To extend the provided security concept, override the default configuration in your extension by carrying out the following steps:
  1. Define a Spring profile containing your custom security definition
  2. Start Data Hub using that profile

By creating a separate profile, you ensure that no conflicting filters are defined, and that you properly override the default security configuration.

A custom Spring Security profile enables you to expand and customize the available user roles. You could also use Spring LDAP and provide a single-sign-on experience. By using an external LDAP server, you could circumvent the need to define user credentials in a properties file.

Using SSL

When using basic authentication, the username and password is encoded using base64 and transmitted in the Authentication header of REST requests. This request can be intercepted and decoded to reveal the username and password. Therefore, it is strongly recommended that you configure your production Tomcat 8.5.x installation to use SSL for all such requests, and to refuse non encrypted connections. To read about enabling SSL with Tomcat, see HTTPS and SSL.

Logging User Authentication Attempts

To capture detailed logging output on user authentications, add an appender in your logback.xml configuration. Then add the logger org.springframework.security, with a logging level of DEBUG as follows:
<logger name="org.springframework.security" level="debug" />

Configuring Data Hub Adapter for Basic Authentication

Basic authentication is also employed for any requests originating in Data Hub Adapter of any SAP Commerce Cloud instance. To ensure that the adapter can connect to Data Hub, provide the username and password for the relevant role in your SAP Commerce Cloud configuration as follows:
# The base URL of the DataHub instance
datahubadapter.datahuboutbound.url=https://localhost:8443/datahub-webapp/v1

# The username and password for basic authentication of DataHub adapter with the DataHub server instance
datahubadapter.datahuboutbound.user=<adminuser>
datahubadapter.datahuboutbound.password=<adminpass>

For further information about configuring basic authentication in the Data Hub Adapter, see Adapter Security.

Configuring Data Hub Adapter for OAuth

OAuth authorization between Data Hub and Data Hub Adapter requires that an OAuth client is configured. A default configuration exists that uses a client called eic. We recommend that you define your own OAuth client. To override the default configuration and use a custom client, add the following properties to your Data Hub local.properties file.
datahub.core.export.service.clientid=eic
datahub.core.export.service.clientsecret=secret

For detailed instructions on adding an OAuth client for Data Hub Adapter in SAP Commerce Cloud Backoffice, see Tutorial: Defining a Data Hub Adapter OAuth Client.