From 64965c294baffb8ddcbc71c0f0ac25b89b4d07c4 Mon Sep 17 00:00:00 2001 From: devmrko Date: Wed, 22 Jul 2026 13:44:09 +0900 Subject: [PATCH] feat(backoffice): retain access policy with Smilegate tables --- sql/adb/71_sg_identity_administration.sql | 51 +++++++++++++ .../resources/mapper/PermissionMapper.xml | 74 ++++++++++--------- .../mapper/ProtectedObjectMapper.xml | 40 +++++----- 3 files changed, 112 insertions(+), 53 deletions(-) diff --git a/sql/adb/71_sg_identity_administration.sql b/sql/adb/71_sg_identity_administration.sql index f2a049c..2ce0649 100644 --- a/sql/adb/71_sg_identity_administration.sql +++ b/sql/adb/71_sg_identity_administration.sql @@ -79,6 +79,57 @@ begin created_at timestamp default systimestamp not null )'); create_if_missing('create sequence sg_audit_event_seq start with 1 increment by 1 nocache'); + create_if_missing('create table sg_protected_object ( + object_id number primary key, + owner varchar2(128) not null, + object_name varchar2(128) not null, + ords_path varchar2(500), + enabled_yn char(1) default ''Y'' not null, + description varchar2(500), + created_at timestamp default systimestamp not null, + updated_at timestamp default systimestamp not null, + constraint sg_protected_object_uq unique (owner, object_name), + constraint sg_protected_object_enabled_ck check (enabled_yn in (''Y'', ''N'')) + )'); + create_if_missing('create table sg_protected_column ( + column_id number primary key, + object_id number not null, + column_name varchar2(128) not null, + sensitive_yn char(1) default ''N'' not null, + visible_role_id number, + sensitivity_level varchar2(30) default ''PUBLIC'' not null, + redaction_method varchar2(30) default ''NONE'' not null, + constraint sg_protected_column_uq unique (object_id, column_name), + constraint sg_protected_column_object_fk foreign key (object_id) references sg_protected_object(object_id), + constraint sg_protected_column_role_fk foreign key (visible_role_id) references sg_app_role(role_id) + )'); + create_if_missing('create table sg_permission ( + perm_id number primary key, + role_id number not null, + target_name varchar2(128) not null, + action_name varchar2(30) not null, + permission_effect varchar2(30) default ''ALLOW'' not null, + created_at timestamp default systimestamp not null, + updated_at timestamp default systimestamp not null, + constraint sg_permission_role_fk foreign key (role_id) references sg_app_role(role_id), + constraint sg_permission_effect_ck check (permission_effect in (''ALLOW'', ''DENY'')) + )'); + create_if_missing('create table sg_permission_rule ( + rule_id number primary key, + perm_id number not null, + rule_column varchar2(128), + rule_type varchar2(50) not null, + rule_value varchar2(2000), + constraint sg_permission_rule_perm_fk foreign key (perm_id) references sg_permission(perm_id) + )'); + create_if_missing('create table sg_permission_column ( + permission_id number not null, + column_name varchar2(128) not null, + constraint sg_permission_column_pk primary key (permission_id, column_name), + constraint sg_permission_column_perm_fk foreign key (permission_id) references sg_permission(perm_id) + )'); + create_if_missing('create sequence sg_permission_seq start with 1 increment by 1 nocache'); + create_if_missing('create sequence sg_permission_rule_seq start with 1 increment by 1 nocache'); end; / diff --git a/src/main/resources/mapper/PermissionMapper.xml b/src/main/resources/mapper/PermissionMapper.xml index 8b9ef68..e2584ed 100644 --- a/src/main/resources/mapper/PermissionMapper.xml +++ b/src/main/resources/mapper/PermissionMapper.xml @@ -59,44 +59,52 @@ @@ -106,46 +114,46 @@ o.object_id, p.action_name AS action, NVL(p.permission_effect, 'ALLOW') AS permission_effect - FROM cb_permission p - JOIN cb_protected_object o ON o.object_name = p.target_name + FROM sg_permission p + JOIN sg_protected_object o ON o.object_name = p.target_name WHERE p.role_id = #{roleId} AND o.object_id = #{objectId} - INSERT INTO cb_permission (perm_id, role_id, target_name, action_name, permission_effect) + INSERT INTO sg_permission (perm_id, role_id, target_name, action_name, permission_effect) SELECT #{permissionId}, #{roleId}, object_name, #{action}, #{permissionEffect} - FROM cb_protected_object + FROM sg_protected_object WHERE object_id = #{objectId} - UPDATE cb_permission + UPDATE sg_permission SET action_name = #{action} WHERE perm_id = #{permissionId} - UPDATE cb_permission + UPDATE sg_permission SET permission_effect = #{permissionEffect} WHERE perm_id = #{permissionId} - DELETE FROM cb_permission_rule + DELETE FROM sg_permission_rule WHERE perm_id = #{permissionId} - INSERT INTO cb_permission_rule (rule_id, perm_id, rule_column, rule_type, rule_value) + INSERT INTO sg_permission_rule (rule_id, perm_id, rule_column, rule_type, rule_value) VALUES ( #{ruleId,jdbcType=NUMERIC}, #{permissionId,jdbcType=NUMERIC}, @@ -156,17 +164,17 @@ - DELETE FROM cb_permission_column + DELETE FROM sg_permission_column WHERE permission_id = #{permissionId} - INSERT INTO cb_permission_column (permission_id, column_name) + INSERT INTO sg_permission_column (permission_id, column_name) VALUES (#{permissionId}, #{columnName}) - DELETE FROM cb_permission + DELETE FROM sg_permission WHERE perm_id = #{permissionId} diff --git a/src/main/resources/mapper/ProtectedObjectMapper.xml b/src/main/resources/mapper/ProtectedObjectMapper.xml index 2e10bed..0a7bfae 100644 --- a/src/main/resources/mapper/ProtectedObjectMapper.xml +++ b/src/main/resources/mapper/ProtectedObjectMapper.xml @@ -4,28 +4,28 @@ @@ -38,8 +38,8 @@ AND object_name NOT LIKE 'BIN$%' AND NOT EXISTS ( SELECT 1 - FROM cb_protected_object po - JOIN cb_permission p ON p.target_name = po.object_name + FROM sg_protected_object po + JOIN sg_permission p ON p.target_name = po.object_name WHERE po.owner = all_objects.owner AND po.object_name = all_objects.object_name AND po.enabled_yn = 'Y' @@ -64,7 +64,7 @@ visible_role_id, NVL(sensitivity_level, CASE sensitive_yn WHEN 'Y' THEN 'CONFIDENTIAL' ELSE 'PUBLIC' END) AS sensitivity_level, NVL(redaction_method, CASE sensitive_yn WHEN 'Y' THEN 'NULLIFY' ELSE 'NONE' END) AS redaction_method - FROM cb_protected_column + FROM sg_protected_column WHERE object_id = #{objectId} ORDER BY column_id @@ -77,7 +77,7 @@ visible_role_id, NVL(sensitivity_level, CASE sensitive_yn WHEN 'Y' THEN 'CONFIDENTIAL' ELSE 'PUBLIC' END) AS sensitivity_level, NVL(redaction_method, CASE sensitive_yn WHEN 'Y' THEN 'NULLIFY' ELSE 'NONE' END) AS redaction_method - FROM cb_protected_column + FROM sg_protected_column WHERE object_id IN #{objectId,jdbcType=NUMERIC} @@ -93,7 +93,7 @@ visible_role_id, NVL(sensitivity_level, CASE sensitive_yn WHEN 'Y' THEN 'CONFIDENTIAL' ELSE 'PUBLIC' END) AS sensitivity_level, NVL(redaction_method, CASE sensitive_yn WHEN 'Y' THEN 'NULLIFY' ELSE 'NONE' END) AS redaction_method - FROM cb_protected_column + FROM sg_protected_column WHERE column_id = #{columnId} @@ -105,21 +105,21 @@ visible_role_id, NVL(sensitivity_level, CASE sensitive_yn WHEN 'Y' THEN 'CONFIDENTIAL' ELSE 'PUBLIC' END) AS sensitivity_level, NVL(redaction_method, CASE sensitive_yn WHEN 'Y' THEN 'NULLIFY' ELSE 'NONE' END) AS redaction_method - FROM cb_protected_column + FROM sg_protected_column WHERE object_id = #{objectId} AND column_name = UPPER(#{columnName,jdbcType=VARCHAR}) - INSERT INTO cb_protected_object (object_id, owner, object_name, ords_path, enabled_yn, description) + INSERT INTO sg_protected_object (object_id, owner, object_name, ords_path, enabled_yn, description) VALUES ( #{objectId}, UPPER(#{command.owner}), @@ -131,7 +131,7 @@ - INSERT INTO cb_protected_column ( + INSERT INTO sg_protected_column ( column_id, object_id, column_name, sensitive_yn, sensitivity_level, redaction_method ) VALUES ( @@ -140,7 +140,7 @@ - UPDATE cb_protected_column + UPDATE sg_protected_column SET sensitivity_level = #{sensitivityLevel,jdbcType=VARCHAR}, redaction_method = #{redactionMethod,jdbcType=VARCHAR}, sensitive_yn = CASE @@ -152,25 +152,25 @@ - UPDATE cb_protected_object + UPDATE sg_protected_object SET ords_path = #{ordsPath,jdbcType=VARCHAR} WHERE object_id = #{objectId,jdbcType=NUMERIC} - UPDATE cb_protected_object + UPDATE sg_protected_object SET description = #{description,jdbcType=VARCHAR} WHERE object_id = #{objectId,jdbcType=NUMERIC} - UPDATE cb_protected_object + UPDATE sg_protected_object SET enabled_yn = 'Y' WHERE object_id = #{objectId} - UPDATE cb_protected_object + UPDATE sg_protected_object SET enabled_yn = 'N' WHERE object_id = #{objectId}