瀚高数据库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 行记录)
相关推荐
资深技术分享员4 小时前
Geejing WebBuilder 数据库连接配置与在线 SQL 工具,运维的左右手
运维·数据库·sql·低代码
ao-weilai5 小时前
MySQL数据库:表操作
数据库·mysql·adb
宵时待雨5 小时前
MySQL数据库1:数据库基础
服务器·数据库·mysql
做运维的阿瑞5 小时前
一个 NULL 让整列姓名消失?MySQL 字符串与日期函数复盘
数据库·sql·mysql
程序猿乐锅5 小时前
【黑马点评 | 第十一篇】关注 Feed 流实现
java·数据库·redis·分布式·后端·缓存·maven
phltxy5 小时前
C 语言文件操作:让数据从内存走向持久化
c语言·网络·数据库
阳光九叶草LXGZXJ6 小时前
达梦数据库-学习-69-DM9主备集群部署
linux·运维·服务器·数据库·sql·学习
jnrjian6 小时前
Connect Microsoft Tools to Oracle Databases powerbi 之类的oracle 客户端
数据库·microsoft·oracle
一条破秋裤6 小时前
Linux 线程同步:条件变量
java·linux·jvm
北京恒星科通刘军6 小时前
灾害监测预警系统中,应急疏散广播的“应急叫应”实际送达率与有效性研究
网络·数据库·人工智能