feat(backoffice): migrate masking rules to Smilegate tables
This commit is contained in:
@@ -145,6 +145,34 @@ begin
|
||||
updated_at timestamp default systimestamp not null,
|
||||
constraint sg_vpd_filter_note_pk primary key (function_owner, function_name)
|
||||
)');
|
||||
create_if_missing('create table sg_masking_rule (
|
||||
rule_id number primary key,
|
||||
rule_code varchar2(100) not null unique,
|
||||
rule_name varchar2(200) not null,
|
||||
template_code varchar2(100) not null,
|
||||
description varchar2(2000),
|
||||
enabled_yn char(1) default ''Y'' not null,
|
||||
created_at timestamp default systimestamp not null,
|
||||
updated_at timestamp default systimestamp not null,
|
||||
constraint sg_masking_rule_enabled_ck check (enabled_yn in (''Y'', ''N''))
|
||||
)');
|
||||
create_if_missing('create table sg_column_masking_rule (
|
||||
column_id number primary key,
|
||||
rule_id number not null,
|
||||
updated_at timestamp default systimestamp not null,
|
||||
constraint sg_column_masking_rule_column_fk foreign key (column_id) references sg_protected_column(column_id),
|
||||
constraint sg_column_masking_rule_rule_fk foreign key (rule_id) references sg_masking_rule(rule_id)
|
||||
)');
|
||||
create_if_missing('create table sg_user_masking_rule (
|
||||
user_id number not null,
|
||||
column_id number not null,
|
||||
decision varchar2(30) not null,
|
||||
active_yn char(1) default ''Y'' not null,
|
||||
updated_at timestamp default systimestamp not null,
|
||||
constraint sg_user_masking_rule_pk primary key (user_id, column_id),
|
||||
constraint sg_user_masking_rule_user_fk foreign key (user_id) references sg_app_user(user_id),
|
||||
constraint sg_user_masking_rule_column_fk foreign key (column_id) references sg_protected_column(column_id)
|
||||
)');
|
||||
end;
|
||||
/
|
||||
|
||||
@@ -210,6 +238,12 @@ create or replace view cb_vpd_policy_note as
|
||||
select object_owner, object_name, policy_name, description, updated_at from sg_vpd_policy_note;
|
||||
create or replace view cb_vpd_filter_note as
|
||||
select function_owner, function_name, description, updated_at from sg_vpd_filter_note;
|
||||
create or replace view cb_masking_rule as
|
||||
select rule_id, rule_code, rule_name, template_code, description, enabled_yn from sg_masking_rule;
|
||||
create or replace view cb_column_masking_rule as
|
||||
select column_id, rule_id, updated_at from sg_column_masking_rule;
|
||||
create or replace view cb_user_masking_rule as
|
||||
select user_id, column_id, decision, active_yn, updated_at from sg_user_masking_rule;
|
||||
|
||||
-- PoC administrator access: both demo operators can manage and query every
|
||||
-- Smilegate game-data object registered in SGMP_POC.
|
||||
|
||||
@@ -4,41 +4,41 @@
|
||||
<mapper namespace="com.cloudhandson.vpdbackoffice.mapper.MaskingRuleMapper">
|
||||
<select id="findAllRules" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
ORDER BY enabled_yn DESC, rule_name, rule_id
|
||||
</select>
|
||||
|
||||
<select id="findEnabledRules" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE enabled_yn = 'Y'
|
||||
ORDER BY rule_name, rule_id
|
||||
</select>
|
||||
|
||||
<select id="findRuleById" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE rule_id = #{ruleId}
|
||||
</select>
|
||||
|
||||
<select id="findRuleByCode" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE rule_code = #{ruleCode}
|
||||
</select>
|
||||
|
||||
<select id="nextRuleId" resultType="long">
|
||||
SELECT NVL(MAX(rule_id), 0) + 1 FROM cb_masking_rule
|
||||
SELECT NVL(MAX(rule_id), 0) + 1 FROM sg_masking_rule
|
||||
</select>
|
||||
|
||||
<insert id="insertRule">
|
||||
INSERT INTO cb_masking_rule (rule_id, rule_code, rule_name, template_code, description, enabled_yn)
|
||||
INSERT INTO sg_masking_rule (rule_id, rule_code, rule_name, template_code, description, enabled_yn)
|
||||
VALUES (#{ruleId}, #{command.ruleCode}, #{command.ruleName}, #{command.templateCode},
|
||||
#{command.description}, 'Y')
|
||||
</insert>
|
||||
|
||||
<update id="updateRuleActive">
|
||||
UPDATE cb_masking_rule
|
||||
UPDATE sg_masking_rule
|
||||
SET enabled_yn = #{enabledYn}
|
||||
WHERE rule_id = #{ruleId}
|
||||
</update>
|
||||
@@ -54,10 +54,10 @@
|
||||
r.rule_name,
|
||||
r.template_code,
|
||||
r.enabled_yn AS rule_enabled_yn
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_protected_column c ON c.column_id = link.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_protected_column c ON c.column_id = link.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
ORDER BY o.owner, o.object_name, c.column_name
|
||||
</select>
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
configured AS (
|
||||
SELECT protected_object.object_name,
|
||||
COUNT(*) AS configured_column_count
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
WHERE protected_object.owner = 'POC_2'
|
||||
AND rule.enabled_yn = 'Y'
|
||||
GROUP BY protected_object.object_name
|
||||
@@ -102,10 +102,10 @@
|
||||
missing_columns AS (
|
||||
SELECT protected_object.object_name,
|
||||
COUNT(*) AS missing_column_count
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
LEFT JOIN redaction_columns policy_column
|
||||
ON policy_column.object_owner = protected_object.owner
|
||||
AND policy_column.object_name = protected_object.object_name
|
||||
@@ -123,10 +123,10 @@
|
||||
WHERE policy_column.object_owner = 'POC_2'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
WHERE protected_object.owner = 'POC_2'
|
||||
AND protected_object.object_name = policy_column.object_name
|
||||
AND protected_column.column_name = policy_column.column_name
|
||||
@@ -180,15 +180,15 @@
|
||||
r.rule_name,
|
||||
r.template_code,
|
||||
r.enabled_yn AS rule_enabled_yn
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_protected_column c ON c.column_id = link.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_protected_column c ON c.column_id = link.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
WHERE c.column_id = #{columnId}
|
||||
</select>
|
||||
|
||||
<insert id="upsertColumnRule">
|
||||
MERGE INTO cb_column_masking_rule dst
|
||||
MERGE INTO sg_column_masking_rule dst
|
||||
USING (SELECT #{columnId} column_id, #{ruleId} rule_id FROM dual) src
|
||||
ON (dst.column_id = src.column_id)
|
||||
WHEN MATCHED THEN UPDATE SET dst.rule_id = src.rule_id, dst.updated_at = SYSTIMESTAMP
|
||||
@@ -197,12 +197,12 @@
|
||||
</insert>
|
||||
|
||||
<delete id="deleteColumnRule">
|
||||
DELETE FROM cb_column_masking_rule
|
||||
DELETE FROM sg_column_masking_rule
|
||||
WHERE column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserRulesForColumn">
|
||||
DELETE FROM cb_user_masking_rule
|
||||
DELETE FROM sg_user_masking_rule
|
||||
WHERE column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
@@ -217,12 +217,12 @@
|
||||
r.template_code,
|
||||
assignment.decision,
|
||||
assignment.active_yn
|
||||
FROM cb_user_masking_rule assignment
|
||||
JOIN cb_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN cb_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_user_masking_rule assignment
|
||||
JOIN sg_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN sg_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
ORDER BY u.user_name, o.owner, o.object_name, c.column_name
|
||||
</select>
|
||||
|
||||
@@ -237,18 +237,18 @@
|
||||
r.template_code,
|
||||
assignment.decision,
|
||||
assignment.active_yn
|
||||
FROM cb_user_masking_rule assignment
|
||||
JOIN cb_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN cb_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_user_masking_rule assignment
|
||||
JOIN sg_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN sg_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
WHERE assignment.user_id = #{userId}
|
||||
AND assignment.column_id = #{columnId}
|
||||
</select>
|
||||
|
||||
<insert id="upsertUserRule">
|
||||
MERGE INTO cb_user_masking_rule dst
|
||||
MERGE INTO sg_user_masking_rule dst
|
||||
USING (SELECT #{userId} user_id, #{columnId} column_id, #{decision} decision FROM dual) src
|
||||
ON (dst.user_id = src.user_id AND dst.column_id = src.column_id)
|
||||
WHEN MATCHED THEN UPDATE SET dst.decision = src.decision, dst.active_yn = 'Y', dst.updated_at = SYSTIMESTAMP
|
||||
@@ -257,7 +257,7 @@
|
||||
</insert>
|
||||
|
||||
<delete id="deleteUserRule">
|
||||
DELETE FROM cb_user_masking_rule
|
||||
DELETE FROM sg_user_masking_rule
|
||||
WHERE user_id = #{userId}
|
||||
AND column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
Reference in New Issue
Block a user