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.
POST / HTTPS/1.1 Host: example.org Content-type: application/json Authorization: Basic YWRtaW46bmltZGE=
Data Hub Users
| 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 |
Accessible Methods |
|---|---|
|
All roles |
GET |
|
ROLE_DATAHUB_INBOUND |
POST, PUT |
|
ROLE_DATAHUB_ADMIN |
GET, DELETE |
|
ROLE_DATAHUB_RO |
GET |
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_Access
.
Overriding the Default Configuration
- Define a Spring profile containing your custom security definition
- 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
<logger name="org.springframework.security" level="debug" />
Configuring Data Hub Adapter for Basic Authentication
# 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
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.