2. Manage Tenants

Make sure that the tenant group exists: Add a Tenant Group.

A tenant group may contain several tenant definitions with the same business meaning but different technical representations, e.g. a BDomain stored in the column BDOMAIN in some objects and in RED_BDOMAIN in others. Each tenant definition is a discover rule that identifies the tenant column in the objects by include and exclude patterns.

2.1. Add a Tenant Rule

Add a tenant rule with API_SCURTY.ADD_TENANT. The rule is identified by its tenant name.

  • Several rules of the same group are combined with “or”; the patterns within one rule are combined with “and”.

  • Include patterns are mandatory, exclude patterns are optional. Besides the patterns, the data type of the column must match: TEXT, NUMBER, or BOOLEAN.

  • If several columns of the same object match rules of the same group, the rule with the lowest value of p_tnt_match_prio wins (0 is the highest priority). If several columns match within one rule, the first column in alphabetical order is taken.

The following example looks for a TEXT column named ‘BDOMAIN’ in all objects ending with ‘TAB’ in the schemas starting with ‘PSV_TEST’.

Example: Add a Tenant Rule for the Column BDOMAIN

 1EXECUTE SCRIPT API_SCURTY.ADD_TENANT(
 2    'TEST_TENANT'          -- p_tnt_group
 3   ,'Tenant1_Test'         -- p_tnt_name
 4   ,1                      -- p_tnt_match_prio
 5   ,'Testing purposes'     -- p_tnt_desc
 6   ,'TEXT'                 -- p_tnt_data_type
 7   ,'BDOMAIN'              -- p_tnt_col_incl_pattern
 8   ,null                   -- p_tnt_col_excl_pattern
 9   ,'PSV_TEST_.*'          -- p_tnt_schema_incl_pattern
10   ,null                   -- p_tnt_schema_excl_pattern
11   ,'.*_TAB'               -- p_tnt_object_incl_pattern
12   ,null                   -- p_tnt_object_excl_pattern
13   ,'.*'                   -- p_tnt_comment_incl_pattern
14   ,null                   -- p_tnt_comment_excl_pattern
15);

The rule is stored in SCURTY.REP_TENANTS:

TNT_GROUP

TNT_NAME

TNT_MATCH_PRIO

TNT_DESC

TNT_DATA_TYPE

TNT_COL_INCL_PATTERN

TNT_COL_EXCL_PATTERN

TNT_SCHEMA_INCL_PATTERN

TNT_SCHEMA_EXCL_PATTERN

TNT_OBJECT_INCL_PATTERN

TNT_OBJECT_EXCL_PATTERN

TNT_COMMENT_INCL_PATTERN

TNT_COMMENT_EXCL_PATTERN

TEST_TENANT

TENANT1_TEST

1

Testing purposes

TEXT

BDOMAIN

(null)

PSV_TEST_.*

(null)

.*_TAB

(null)

.*

(null)

2.2. Change a Tenant Rule

A tenant rule is changed with API_SCURTY.CHANGE_TENANT. NULL leaves a parameter unchanged, while a blank (’ ‘) restores its default value.

In the following example all schemas ending with ‘_DR’ are excluded from the rule.

Example: Exclude the DR Schemas

 1EXECUTE SCRIPT API_SCURTY.CHANGE_TENANT(
 2    'TEST_TENANT'      -- p_tnt_group
 3   ,'Tenant1_Test'     -- p_tnt_name
 4   ,null               -- p_tnt_match_prio
 5   ,null               -- p_tnt_desc
 6   ,null               -- p_tnt_data_type
 7   ,null               -- p_tnt_col_incl_pattern
 8   ,null               -- p_tnt_col_excl_pattern
 9   ,null               -- p_tnt_schema_incl_pattern
10   ,'.*_DR'            -- p_tnt_schema_excl_pattern
11   ,null               -- p_tnt_object_incl_pattern
12   ,null               -- p_tnt_object_excl_pattern
13   ,null               -- p_tnt_comment_incl_pattern
14   ,null               -- p_tnt_comment_excl_pattern
15);

The rule in SCURTY.REP_TENANTS has changed:

TNT_GROUP

TNT_NAME

TNT_MATCH_PRIO

TNT_DESC

TNT_DATA_TYPE

TNT_COL_INCL_PATTERN

TNT_COL_EXCL_PATTERN

TNT_SCHEMA_INCL_PATTERN

TNT_SCHEMA_EXCL_PATTERN

TNT_OBJECT_INCL_PATTERN

TNT_OBJECT_EXCL_PATTERN

TNT_COMMENT_INCL_PATTERN

TNT_COMMENT_EXCL_PATTERN

TEST_TENANT

TENANT1_TEST

1

Testing purposes

TEXT

BDOMAIN

(null)

PSV_TEST_.*

.*_DR

.*_TAB

(null)

.*

(null)

2.3. Remove a Tenant Rule

Use API_SCURTY.REMOVE_TENANT to remove a tenant rule.

Example: Remove the Tenant Rule

1EXECUTE SCRIPT API_SCURTY.REMOVE_TENANT(
2    'TEST_TENANT'      -- p_tnt_group
3   ,'Tenant1_Test'     -- p_tnt_name
4);

The rule ‘TENANT1_TEST’ is removed from SCURTY.REP_TENANTS. Like all rule changes, tenant rules take effect with the next security refresh.