28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

((Year = 2006) OR (Year BT 2008 and 2010)) AND (Country IN ("USA",<br />

"Germany"))) OR (Country = "France")<br />

Dynamic Value Filters in the Attribute Restriction of Analytic Privileges<br />

The attribute restriction of an analytic privilege specifies the value range that the user is permitted to access using<br />

value filters. In addition to static scalar values, stored procedures can be used to define filters. This allows userspecific<br />

filter conditions to be determined dynamically in runtime, for example, by querying specified tables or<br />

views. As a result, the same analytic privilege can be applied to many users, while the filter values for authorization<br />

can be updated and changed independently in the relevant database tables. In addition, application developers<br />

have full control not only to design and manage such filter conditions, but also to design the logic for obtaining the<br />

relevant filter values for the individual user at runtime.<br />

Procedures used to define filter conditions must have the following properties:<br />

● They must be DEFINER procedures.<br />

● They must be read-only procedures.<br />

● A procedure with a predefined signature must be used. The following conditions apply:<br />

○ No input parameter<br />

○ Only 1 output parameter as table type with one single column for the IN operator<br />

○ Only 1 output parameter of a scalar type for all unary operators, such as EQUAL<br />

○ Only 2 output parameters of a scalar type for the binary operator BETWEEN<br />

● Only the following data types are supported as the scalar types and the data type of the column in the table<br />

type:<br />

○ Date/Time types DATE, TIME, SECONDDATE, and TIMESTAMP<br />

○ Numeric types TINYINT, SMALLINT, INTEGER, BIGINT, DECIMAL, REAL, and DOUBLE<br />

○ Character string types VARCHAR and NVARCHAR<br />

○ Binary type VARBINARY<br />

When the procedure is executed as part of the authorization check in runtime, the following constraints apply:<br />

● The user who must be authorized is the database user who executes the query accessing a secured view. This<br />

is the session user. The database table or view used in the procedure should therefore contain a column to<br />

store the user name of the session user. The procedure can then filter by this column using the SQL function<br />

SESSION_USER. This table or view should only be accessible to the procedure owner.<br />

● The user executing the procedure is the _SYS_REPO user. In the case of procedures activated in the <strong>SAP</strong><br />

<strong>HANA</strong> modeler, _SYS_REPO is the owner of the procedures. For procedures created in SQL, the EXECUTE<br />

privilege on the procedure must be granted to the _SYS_REPO user.<br />

● If the procedure fails to execute, the user’s query stops processing and a “Not authorized” error is returned .<br />

The root cause can be investigated in the error trace file of the indexserver,<br />

indexserver_alert_.trc.<br />

When designing and implementing procedures as filter for dynamic analytic privileges, bear the following in mind:<br />

● To avoid a recursive analytic privilege check, the procedures should only select from database tables or views<br />

that are not subject to an authorization check based on analytic privileges. In particular, views activated in the<br />

<strong>SAP</strong> <strong>HANA</strong> modeler are to be avoided completely as they are automatically registered for the analytic<br />

privilege check.<br />

● The execution of procedures in analytic privileges slows down query processing compared to analytic<br />

privileges containing only static filters. Therefore, procedures used in analytic privileges must be designed<br />

carefully.<br />

336<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Setting Up Roles and Authorizations

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!