Best Practices and Recommendations For Developing Roles in SAP HANA
Best Practices and Recommendations For Developing Roles in SAP HANA
Document history
Version Release Date Change description Contact
References
General
• SAP HANA Developer Guide: Explains how to build applications using SAP HANA,
including how to model data, how to write procedures, and how to build application
logic in SAP HANA Extended Application Services, classic model.
• SAP HANA XSA Developer Guide: Explains how to build applications using SAP
HANA, including how to model persistent and analytic data, how to write procedures,
and how to build application logic in SAP HANA Extended Application Services ad-
vanced model (XS advanced).
• SAP HANA Security Guide: Is the entry point for all information relating to the secure
operation and configuration of SAP HANA.
• SAP HANA Security Checklist: Offers recommendations and information about opti-
mizing your security configuration to help you run your SAP HANA securely.
• SAP Note 2465027 - Deprecation of SAP HANA extended application services, clas-
sic model and SAP HANA Repository.
Migration
• SAP HANA XS Advanced Migration Guide: Explains how to prepare, migrate, and de-
ploy applications from the XS classic model to the XS advanced model.
Glossary
Following abbreviations will be used throughout the document:
Acronym Meaning
DU Delivery unit
TABLE OF CONTENTS
Document history ................................................................................................................................... 2
References ............................................................................................................................................... 2
Glossary ................................................................................................................................................... 3
1. INTRODUCTION ...................................................................................................................... 6
2. PREPARATION ........................................................................................................................ 7
2.1 Prerequisites ........................................................................................................................... 7
2.2 SAP HANA release .................................................................................................................. 7
3. WHAT IS CHANGED FROM XSC TO XSA?........................................................................... 8
3.1 Development Scenarios ......................................................................................................... 8
3.1.1 SAP HANA and XSC ............................................................................................................... 8
3.1.2 SAP HANA and XSA ............................................................................................................... 9
3.1.3 Orgs, spaces and projects ................................................................................................... 10
3.2 Database roles ...................................................................................................................... 11
3.2.1 Design-time roles created in XSC ....................................................................................... 11
3.2.2 Design-time roles created in XSA ....................................................................................... 11
3.2.3 Comparing design-time roles between XSC and XSA ...................................................... 12
4. HDI .......................................................................................................................................... 14
4.1 Container model.................................................................................................................... 14
4.2 Container groups .................................................................................................................. 14
4.3 Container isolation ............................................................................................................... 15
4.4 Breaking the container isolation ......................................................................................... 16
5. ROLE DEVELOPMENT IN XSA ............................................................................................ 17
5.1 The steps before development can start............................................................................ 17
5.2 Equip the HDI container with external privileges .............................................................. 17
5.2.1 Between HDI containers in the same space ...................................................................... 18
5.2.2 Between HDI containers in different spaces and external objects ................................. 18
5.2.2.1 Using a UPS with a procedure grantor ................................................................................... 19
5.2.2.2 GRANT to #OO user directly .................................................................................................. 20
5.3 Role development process .................................................................................................. 20
6. BEST PRACTICES AND RECOMMENDATIONS ................................................................. 21
6.1 Organization and spaces ..................................................................................................... 21
6.2 Setup ...................................................................................................................................... 21
6.3 Other considerations and hints........................................................................................... 22
7. MIGRATING ROLES FROM XSC TO XSA ........................................................................... 23
1. INTRODUCTION
The objective of this document is to describe the best practices and general recommendations on
the role development process for SAP HANA database (HDB) access roles with SAP HANA and
SAP HANA Extended application services, advanced model (XSA).
XSA provides a comprehensive platform for the development and execution of native data-inten-
sive applications that run efficiently in SAP HANA. It thus succeeds XS classic (XSC) as the default
application programming model for SAP HANA. This implies that XSA defined and deployed roles
will substitute the XSC defined and activated design-time roles.
The purpose of this document is not to replace the SAP HANA XSA Developer Guide, but to pro-
vide additional information and recommendations on how to address the common challenges on
the role development process with XSA.
Additionally, in this document, we deliver and describe SAP HANA Deployment Infrastructure
(HDI)-based role templates for administrative tasks in SAP HANA database. This HDI-based role
templates can be used by costumers as a starting point for the creation of their own roles.
Please note that this document does not cover user management of XSA applications themselves currently!
6
Preparation
2. PREPARATION
2.1 Prerequisites
This document aims at administrators and role developers who:
• are experienced with SAP HANA,
• are familiar with SAP HANA privileges, roles as well as XSC and
• have basic knowledge about XSA (e.g. have attended the latest openSAP course on SAP
HANA development).
Furthermore, SAP note 2347931 explains the relation between SAP HANA and release versions of
the SAP HANA XS, advanced model components.
7
What is changed from XSC to XSA?
XSC
8
What is changed from XSC to XSA?
An HDI container can be seen as a database schema and we can have multiple HDI containers
within the HDB. All database objects deployed within the container are owned by container-specific
technical object owner.
HDI
C1 C2 C3
(owned by (owned by (owned by
C1#OO) C2#OO) C2#OO)
Transportability • SAP HANA Application Lifecycle Manager CTS+ of the SAP NetWeaver ABAP application server
• The change and transport system (CTS+)
of the SAP NetWeaver ABAP application
server
• SAP HANA Transport Container (HTC)
Refer to section “Catalog Roles and Design-Time Roles Compared” of the SAP HANA Security
Guide for SAP HANA Platform for more info.
In the following diagram, we can see the differences between roles (design-time and run-time
roles) in XSC and in XSA.
XS classic XS advanced
R R R
R R
R R
R HANA activate deploy
HANA Catalog
There are also differences in the way a role can be granted depending if they are global roles
(XSC) or schema-local roles (XSA). Global roles cannot be granted or revoked with ROLE ADMIN
system privilege, but through the SYS_REPO API, thus the execute privilege on the procedures is
required.
Conversely, schema-local roles can be granted or revoked with ROLE ADMIN system privilege
and/or through the container-local API. This characteristic allows us to grant all the roles in the sys-
tem by having ROLE ADMIN system privilege or only grant roles that are contained in a specific
container where we have the execute privilege on container-local API.
4. HDI
With XSA it was also introduced the HDI which is a service layer of the HDB that simplifies the de-
ployment of HDB artifacts.
14
HDI
By default, references to external objects are not allowed. For example, view X has no direct refer-
ence to table ERP.Y:
The HDI container isolation also affects the creation of database roles through XSA. When we cre-
ate a database role, using XSA, the database role will be deployed within an HDI container and it
will be owned by the database object owner. Thus, to be able to deploy the roles, the role can only
contain privileges that are assigned to the #OO user with GRANT / ADMIN option. Otherwise, the
deployment will fail due to a “Missing authorization error”.
In case of database roles, the approach is similar. To deploy successfully a database role, all the
privileges that are included in the role should be granted to the #OO user with GRANT / ADMIN
option in advance.
There are different alternative options how to grant the database-level privileges to the #OO user.
These options are described in the following section “Equip the HDI container with external privi-
leges”.
For illustration purposes, assume to deploy the database roles within the HDI container named
“C1” and grant all the external privileges to the container object owner user (C1#OO user) with
GRANT /ADMIN option in advance.
17
Role development in XSA
When two or more containers are in the same space, every HDI container is shared (accessible) to
other HDI containers in the same space. This is possible as it exists a so-called trusted setup be-
tween all the resources located in the same space. In this case, there is a shortcut mechanism
where the C1 container itself can obtain privileges for the other container in the same space, e.g.
C2.
The following two options are recommended to grant the privileges of an external object to the
C1#OO user:
If user A will be used for building roles only containing privileges already granted to SYSTEM by default (e.g.
SYSTEM PRIVILEGES), the SYSTEM user could be used as user A. If user A will be used for building roles
containing privileges of e.g. developed objects, a dedicated user should be created and used as user A in-
stead of SYSTEM user.
Additionally, in the XSA space, we need to define a UPS with the user B credentials. This UPS will
be used by the HDI deployer (application used to “prepare” the HDI container) to provide automati-
cally the required privileges to the #OO user.
To define which external privileges are going to be granted to the #OO user, we need to maintain
in the XSA project the .hdbgrants file, specifying the UPS as granting service.
On startup, the HDI deployer will process the .hdbgrants file, connect to the database using the
UPS credentials (user B credentials), and execute the procedure that grants the privileges to the
#OO user.
Again, do not use the user SYSTEM as the user A, except for role-building with privileges granted to the
SYSTEM user by default - e.g. SYSTEM PRIVILEGES.
The user account that has all the required privileges (user A) can be deactivated and the creden-
tials are not shared. Instead, the credentials of the user B, with very limited privileges, are shared
to define the UPS.
Additionally, further security validations can be implemented within the procedure´s logic to avoid
granting the privileges to a different user than container object owners. For example, validating that
the grantee user is deactivated and the username ends with “#OO” characters.
The procedure grantor mechanism is supported as of version 3.4.1 of the @sap/hdi-deploy component in
XSA.
For further details on how to create the different development objects needed for role developing –
refer to SAP HANA Developer Guide for SAP HANA XS Advanced Model.
6.2 Setup
It is recommended to use the option “Using a UPS with a procedure grantor” in all environments as
a mechanism to grant the external privileges to the #OO user of the container where the database
roles are being deployed.
With this mechanism, no activated user needs to have all the granted privileges. Only the call of
the procedure is exposed, and the procedure can contain various additional security checks.
To avoid delays in the development process due to missing authorizations in the container, de-
pending on your scenario the following recommendations apply when developing roles:
• only containing privileges already granted to SYSTEM by default (e.g. SYSTEM PRIVI-
LEGES), the SYSTEM user should be used as the user holding all the privileges (User A as
explained in section “Using a UPS with a procedure grantor”).
In this case, the space where the UPS is exposed should be used exclusively for role development and not
for application development.
21
Best practices and recommendations
www.sap.com/contactsap
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable
for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements accompany-
ing such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality men-
tioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all
subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to
deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are
cautioned not to place undue reliance on these forward-looking statements, and they should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the trademarks of their respective companies. See www.sap.com/trademark for additional trademark information and notices.