瀚高数据库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 行记录)
相关推荐
Random Glow3 分钟前
聚簇索引:为什么主键顺序决定插入性能
数据库·mysql·性能优化·innodb·索引
软件技术NINI4 分钟前
基于PHP和MySQL的快递代收点管理系统的设计与实现
开发语言·javascript·数据库·mysql·毕业设计·php·毕设
吹什么轩28 分钟前
MySQL 增删改查(CRUD)完全指南:从 INSERT 到 GROUP BY
数据库·mysql
为思念酝酿的痛43 分钟前
MySQL表的约束
数据库·mysql
时间售卖铺1 小时前
MySQL存储过程流程控制全解析
运维·数据库·mysql·云原生
拾起零碎1 小时前
U8/触发器,把自定义项写入批次档案
数据库
IT19959 小时前
Fail2Ban 防护 MySQL 实战|登录失败 3 次,IP 封禁 24 小时
数据库·mysql
夕除9 小时前
redis--IO 多路复用(select + poll)
数据库·sql
lzhdim13 小时前
100条常用SQL语句
数据库·sql·mysql·mybatis
天河归来13 小时前
从原始消息到业务数据:三层数据架构的设计与实践
数据库·数据仓库·架构