瀚高数据库V9.0.5数据脱敏完整配置步骤

文章目录

环境

系统平台:N/A

版本:9.0.5

文档用途

本文旨在介绍瀚高数据库V9.0.5数据脱敏功能的完整配置步骤。更详尽的数据脱敏功能内容可以参考官方手册相关章节。

详细信息

相关用户和表demo创建步骤如下:

创建相关测试用户

sql 复制代码
highgo=> \c highgo highgo
用户 highgo 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "highgo".
highgo=# create user u1 password 'highgo';
CREATE ROLE
highgo=# create user u2 password 'highgo';
CREATE ROLE
highgo=# create user u3 password 'highgo';

在用户u3下创建测试表,并赋予u1和u2用户select权限

sql 复制代码
highgo=# \c highgo u3
用户 u3 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u3".
highgo=> create table test(id int, col1 varchar,info text);
CREATE TABLE
highgo=> insert into test values(1,'highgo','database');
INSERT 0 1
highgo=> insert into test values(2,'postgres','opensource');
INSERT 0 1
highgo=> grant select on test to u1,u2;
GRANT

一、启用数据脱敏功能

1.修改配置文件postgresql.conf,给shared_preload_libraries参数追加hg_redaction,并设置hg_redaction.enable=on。随后重新启动数据库。(重启涉及数据库服务中断,需要协调停机窗口进行)

修改前:

sql 复制代码
highgo=# show shared_preload_libraries ;
                                                     shared_preload_libraries                                                     
----------------------------------------------------------------------------------------------------------------------
 gb18030_2022, restricted_dba, pg_audit, credcheck, hg_sysmac, sqlite_fdw, ora_synonym, liboracle_parser, ivorysql_ora, pg_object
highgo=> show hg_redaction.enable;
 hg_redaction.enable 
---------------------
 off

修改后:

sql 复制代码
highgo=# show shared_preload_libraries ;
                                                            shared_preload_libraries                                                            
----------------------------------------------------------------------------------------------------------------------
 gb18030_2022, restricted_dba, pg_audit, credcheck, hg_sysmac, sqlite_fdw, ora_synonym, liboracle_parser, ivorysql_ora, pg_object, hg_redaction
highgo=> show hg_redaction.enable;
 hg_redaction.enable 
---------------------
 on

2.登录数据库管理员用户在待脱敏库创建扩展

sql 复制代码
[highgo@node1 bin]$ ./psql highgo highgo
用户 highgo 的口令:
psql (14.20)
hgdb-client-V9.0.5
输入 "help" 来获取帮助信息.
highgo=# create extension hg_redaction;
CREATE EXTENSION
highgo=# \dx hg_redaction
                     已安装扩展列表
     名称     | 版本 | 架构模式 |          描述          
--------------+------+----------+------------------------
 hg_redaction | 1.0  | public   | support data redaction
(1 行记录)

二、创建一个完整脱敏策略

登录超级管理员/安全员用户创建完整脱敏策略,仅对u1用户生效

sql 复制代码
highgo=> \c highgo highgo
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "highgo".
highgo=> create redaction policy p1 on test for(user='u1') add column  col1 using hg_security.redact_all;
CREATE REDACTION POLICY

登录u1用户查看test表中col1列数据已完全脱敏

sql 复制代码
highgo=> \c highgo u1
用户 u1 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u1".
highgo=> select * from test;
 id |   col1   |    info
----+----------+------------
  1 | xxxxxx   | database
  2 | xxxxxxxx | opensource
(2 行记录)

登录u2用户查看test表完整数据

sql 复制代码
highgo=> \c highgo u2
用户 u2 的口令:
hgdb-client-V9.0.5
您现在已经连接到数据库 "highgo",用户 "u2".
highgo=> select * from test;
 id |   col1   |    info
----+----------+------------
  1 | highgo   | database
  2 | postgres | opensource
(2 行记录)
相关推荐
hacker7072 小时前
DBeaver 鸿蒙 PC 适配全记录:在 HarmonyOS 桌面端原生重建一个通用数据库工具
数据库·华为·harmonyos
Cicada1282 小时前
分享我一直在用的一套 AI 记忆系统方案
大数据·数据库·人工智能
todoitbo2 小时前
SQL Server数据库迁移:V9R4C019 如何接住存量 T-SQL 批处理
数据库·sql·国产数据库
云飞云共享云桌面2 小时前
不用批量采购工作站|液压设备制造,SolidWorks 多人共享服务器方案
运维·服务器·网络·数据库·制造
写后端的胖头鱼2 小时前
【高频面试题】SQL 查询慢怎么排查
数据库·sql·mysql·oracle·慢查询·高频面试题
蓝速科技2 小时前
口岸政务窗口双屏翻译机落地应用指南
运维·数据结构·数据库·人工智能·科技·政务
风哥2号2 小时前
数据库教程FGMT20‑Oracle容灾体系架构与数据库升级迁移方案
数据库·oracle·架构
阿里云基础软件2 小时前
一句话看透 JVM,SysOM 诊断 Skill 新增 Java 应用诊断能力
java·开发语言·jvm·人工智能·操作系统·sysom 诊断 skill
wudongfang6663 小时前
mysql全量同步数据改增量
数据库·mysql