<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>数据脱敏 on SphereEx-DBPlusSuite</title><link>//docs.sphere-ex.com/sphereex-dbplussuite/master/zh/docs/reference/driver/special-api/mask/</link><description>Recent content in 数据脱敏 on SphereEx-DBPlusSuite</description><generator>Hugo -- gohugo.io</generator><language>zh</language><atom:link href="//docs.sphere-ex.com/sphereex-dbplussuite/master/zh/docs/reference/driver/special-api/mask/index.xml" rel="self" type="application/rss+xml"/><item><title>动态脱敏</title><link>//docs.sphere-ex.com/sphereex-dbplussuite/master/zh/docs/reference/driver/special-api/mask/mask/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>//docs.sphere-ex.com/sphereex-dbplussuite/master/zh/docs/reference/driver/special-api/mask/mask/</guid><description>动态脱敏 # 简介 # 在 DBPlusEngine-Proxy 中可以配置 SphereEx:MASK_ROLE 脱敏算法，不同角色登录 DBPlusEngine-Proxy 后显示不同的脱敏数据。而该角色是 DBPlusEngine-Proxy 中用户的角色。 而当使用 DBPlusEngine-Driver 时，配置的 jdbc user 又是固定值，没法和业务的用户角色进行联动，如果想根据业务系统的用户角色实现动态脱敏怎么样办呢？此时引入了 DynamicACLMatchingMaskPlugin SPI。 用户可以实现 DynamicACLMatchingMaskPlugin SPI， 配合在 DBPlusEngine-Proxy 中配置的 SphereEx:MASK_ROLE 脱敏算法实现这种需求。
主要使用场景：
集成 DBPlusEngine-Driver 的应用根据业务系统用户角色实现动态脱敏 操作步骤 # 在 DBPlusEngine-Proxy 中配置好使用 SphereEx:MASK_ROLE 脱敏算法的脱敏规则，配置好应用中需要脱敏的角色。 在应用中实现 DynamicACLMatchingMaskPlugin SPI，返回当前用户角色。 规则配置 # 在 DBPlusEngine-Proxy 中配置脱敏规则，如定义当应用系统用户角色为 guest 时会对 t_user 表的 name 和 phone 列进行脱敏显示。
CREATE MASK RULE IF NOT EXISTS `t_user` ( COLUMNS( (NAME=`name`, ALGORITHM_GROUPS( (MASK_ALGORITHM(TYPE(NAME=&amp;#39;SphereEx:MASK_CHINESE_NAME&amp;#39;, PROPERTIES(&amp;#39;first-n&amp;#39;=&amp;#39;1&amp;#39;,&amp;#39;last-m&amp;#39;=&amp;#39;1&amp;#39;,&amp;#39;replace-char&amp;#39;=&amp;#39;*&amp;#39;))), MATCHING_ALGORITHM(TYPE(NAME=&amp;#39;SphereEx:MASK_ROLE&amp;#39;, PROPERTIES(&amp;#39;role-lists&amp;#39;=&amp;#39;guest&amp;#39;))))) ), (NAME=`phone`, ALGORITHM_GROUPS( (MASK_ALGORITHM(TYPE(NAME=&amp;#39;KEEP_FIRST_N_LAST_M&amp;#39;, PROPERTIES(&amp;#39;first-n&amp;#39;=&amp;#39;1&amp;#39;,&amp;#39;last-m&amp;#39;=&amp;#39;1&amp;#39;,&amp;#39;replace-char&amp;#39;=&amp;#39;*&amp;#39;))), MATCHING_ALGORITHM(TYPE(NAME=&amp;#39;SphereEx:MASK_ROLE&amp;#39;, PROPERTIES(&amp;#39;role-lists&amp;#39;=&amp;#39;guest&amp;#39;))))) ) )); SPI 实现 # 在应用自定义类实现 com.</description></item></channel></rss>