如何弄微信小程序店铺,怎么做神马搜索排名seo,如何做律所网站,seo优化关键词是什么意思目录 背景ShardingSphere脱敏规则sharding-jdbc数据脱敏数据脱敏配置数据分片 数据脱敏配置 背景
对互联网公司、传统行业来说#xff0c;数据安全一直是极为重视和敏感的话题。数据脱敏是指对某些敏感信息通过脱敏规则进行数据的变形#xff0c;实现敏感隐私数据的可靠保护… 目录 背景ShardingSphere脱敏规则sharding-jdbc数据脱敏数据脱敏配置数据分片 数据脱敏配置 背景
对互联网公司、传统行业来说数据安全一直是极为重视和敏感的话题。数据脱敏是指对某些敏感信息通过脱敏规则进行数据的变形实现敏感隐私数据的可靠保护。
Apache ShardingSphere根据业界对脱敏的需求及业务改造痛点提供了一套完整、安全、透明化、低改造成本的数据脱敏整合解决方案。
ShardingSphere脱敏规则
脱敏配置主要分为四部分数据源配置加密器配置脱敏表配置以及查询属性配置其详情如下图所示 数据源配置是指DataSource的配置。
加密器配置是指使用什么加密策略进行加解密。目前ShardingSphere内置了两种加解密策略AES/MD5。用户还可以通过实现ShardingSphere提供的接口自行实现一套加解密算法。
脱敏表配置用于告诉ShardingSphere数据表里哪个列用于存储密文数据cipherColumn、哪个列用于存储明文数据plainColumn以及用户想使用哪个列进行SQL编写logicColumn。
查询属性的配置当底层数据库表里同时存储了明文数据、密文数据后该属性开关用于决定是直接查询数据库表里的明文数据进行返回还是查询密文数据通过Encrypt-JDBC解密后返回。
脱敏处理流程图 sharding-jdbc数据脱敏
sharding-jdbc与spring boot集成之后通过配置我们就可以使用sharding-jdbc的功能
数据脱敏配置
下面是单独配置数据脱敏的配置
#数据源名称多数据源以逗号分隔
spring.shardingsphere.datasource.nameds#数据源连接信息和相关配置
spring.shardingsphere.datasource.ds.typeorg.apache.commons.dbcp2.BasicDataSource
spring.shardingsphere.datasource.ds.driver-class-namecom.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds.urljdbc:mysql://127.0.0.1:3306/encrypt?serverTimezoneUTCuseSSLfalse
spring.shardingsphere.datasource.ds.usernameroot
spring.shardingsphere.datasource.ds.password
spring.shardingsphere.datasource.ds.max-total100spring.shardingsphere.encrypt.encryptors.encryptor_aes.typeaes
spring.shardingsphere.encrypt.encryptors.encryptor_aes.props.aes.key.value123456
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.plainColumnuser_decrypt
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.cipherColumnuser_encrypt
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.assistedQueryColumnuser_assisted
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.encryptorencryptor_aes#打印sql语句
spring.shardingsphere.props.sql.showtrue
spring.shardingsphere.props.query.with.cipher.columntrue数据源相关配置省略可以看我之前的文章下面主要介绍数据脱敏的相关配置
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.encryptorencryptor_aes加密器名字上述配置用于指定对t_order表的user_id列进行加密时使用的加密器表和列是根据我们实际情况配置的
格式spring.shardingsphere.encrypt.tables.table-name.columns.logic-column-name.encryptor
spring.shardingsphere.encrypt.encryptors.encryptor_aes.typeaes配置加密器类型可自定义或选择内置加密算法MD5/AES
encryptor_aes为加密器的名称对应我们定义的encryptor
spring.shardingsphere.encrypt.encryptors.encryptor_aes.props.aes.key.value123456配置 AES 加密算法的密钥AES算法必配
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.plainColumnuser_decrypt存储明文的字段不需要存储可不配置
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.cipherColumnuser_encrypt存储密文的字段
spring.shardingsphere.encrypt.tables.t_order.columns.user_id.assistedQueryColumnuser_assisted辅助查询字段针对ShardingQueryAssistedEncryptor类型的加解密器进行辅助查询一般不需要配置
spring.shardingsphere.props.query.with.cipher.columntrue设置是否在查询结果中包含加密列的明文值当将该属性设置为 true 时ShardingSphere 在执行查询操作时会将加密列的明文值包含在查询结果中返回
数据分片 数据脱敏配置
spring.shardingsphere.datasource.namesds_0,ds_1spring.shardingsphere.datasource.ds_0.typecom.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds_0.driver-class-namecom.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds_0.jdbc-urljdbc:mysql://localhost:3306/demo_ds_0
spring.shardingsphere.datasource.ds_0.usernameroot
spring.shardingsphere.datasource.ds_0.passwordspring.shardingsphere.datasource.ds_1.typecom.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds_1.driver-class-namecom.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds_1.jdbc-urljdbc:mysql://localhost:3306/demo_ds_1
spring.shardingsphere.datasource.ds_1.usernameroot
spring.shardingsphere.datasource.ds_1.passwordspring.shardingsphere.sharding.default-database-strategy.inline.sharding-columnuser_id
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expressionds_$-{user_id % 2}spring.shardingsphere.sharding.tables.t_order.actual-data-nodesds_$-{0..1}.t_order_$-{0..1}
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-columnorder_id
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expressiont_order_$-{order_id % 2}
spring.shardingsphere.sharding.tables.t_order.key-generator.columnorder_id
spring.shardingsphere.sharding.tables.t_order.key-generator.typeSNOWFLAKE
spring.shardingsphere.sharding.tables.t_order_item.actual-data-nodesds_$-{0..1}.t_order_item_$-{0..1}
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.sharding-columnorder_id
spring.shardingsphere.sharding.tables.t_order_item.table-strategy.inline.algorithm-expressiont_order_item_$-{order_id % 2}
spring.shardingsphere.sharding.tables.t_order_item.key-generator.columnorder_item_id
spring.shardingsphere.sharding.tables.t_order_item.key-generator.typeSNOWFLAKE
spring.shardingsphere.sharding.encrypt-rule.encryptors.encryptor_aes.typeaes
spring.shardingsphere.sharding.encrypt-rule.encryptors.encryptor_aes.props.aes.key.value123456
spring.shardingsphere.sharding.encrypt-rule.tables.t_order.columns.user_id.plainColumnuser_decrypt
spring.shardingsphere.sharding.encrypt-rule.tables.t_order.columns.user_id.cipherColumnuser_encrypt
spring.shardingsphere.sharding.encrypt-rule.tables.t_order.columns.user_id.assistedQueryColumnuser_assisted
spring.shardingsphere.sharding.encrypt-rule.tables.t_order.columns.user_id.encryptorencryptor_aes