forked from github/dataease
fix(数据集): 数据集脱敏规则
This commit is contained in:
parent
d4eb6266d9
commit
72026e9a6a
@ -1011,7 +1011,7 @@ public class ChartDataBuild {
|
||||
} else {
|
||||
switch (columnPermissionItem.getDesensitizationRule().getCustomBuiltInRule()) {
|
||||
case RetainBeforeMAndAfterN:
|
||||
if (StringUtils.isEmpty(originStr) || originStr.length() < columnPermissionItem.getDesensitizationRule().getM() + columnPermissionItem.getDesensitizationRule().getN() + 1) {
|
||||
if (StringUtils.isEmpty(originStr) || originStr.length() <= columnPermissionItem.getDesensitizationRule().getM() + columnPermissionItem.getDesensitizationRule().getN() + 1) {
|
||||
desensitizationStr = String.join("", Collections.nCopies(columnPermissionItem.getDesensitizationRule().getM(), "X")) + "***" + String.join("", Collections.nCopies(columnPermissionItem.getDesensitizationRule().getN(), "X"));
|
||||
} else {
|
||||
desensitizationStr = StringUtils.substring(originStr, 0, columnPermissionItem.getDesensitizationRule().getM() - 1) + "***" + StringUtils.substring(originStr, originStr.length() - columnPermissionItem.getDesensitizationRule().getN(), originStr.length() - 1);
|
||||
|
@ -13,6 +13,7 @@ import io.dataease.plugins.common.dto.chart.ChartCustomFilterItemDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.*;
|
||||
import io.dataease.plugins.xpack.auth.dto.response.Item;
|
||||
import io.dataease.plugins.xpack.auth.service.ColumnPermissionService;
|
||||
import io.dataease.plugins.xpack.auth.service.RowPermissionService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -112,14 +113,14 @@ public class PermissionService {
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(fieldRoleColumnPermissionItems)) {
|
||||
if (fieldRoleColumnPermissionItems.stream().map(ColumnPermissionItem::getOpt).collect(Collectors.toList()).contains(ColumnPermissionConstants.Desensitization)) {
|
||||
desensitizationList.put(field.getDataeaseName(), fieldUserColumnPermissionItems.get(0));
|
||||
desensitizationList.put(field.getDataeaseName(), fieldRoleColumnPermissionItems.get(0));
|
||||
result.add(field);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(fieldDeptColumnPermissionItems)) {
|
||||
if (fieldDeptColumnPermissionItems.stream().map(ColumnPermissionItem::getOpt).collect(Collectors.toList()).contains(ColumnPermissionConstants.Desensitization)) {
|
||||
desensitizationList.put(field.getDataeaseName(), fieldUserColumnPermissionItems.get(0));
|
||||
desensitizationList.put(field.getDataeaseName(), fieldDeptColumnPermissionItems.get(0));
|
||||
result.add(field);
|
||||
}
|
||||
return;
|
||||
@ -209,34 +210,46 @@ public class PermissionService {
|
||||
dataSetColumnPermissionsDTO.setAuthTargetType("user");
|
||||
datasetColumnPermissions.addAll(columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO));
|
||||
if (CollectionUtils.isNotEmpty(roleIds)) {
|
||||
dataSetColumnPermissionsDTO.setAuthTargetIds(roleIds);
|
||||
dataSetColumnPermissionsDTO.setAuthTargetType("role");
|
||||
List<DataSetColumnPermissionsDTO> roleColumnPermissionsDTOS = new ArrayList<>();
|
||||
for (DataSetColumnPermissionsDTO columnPermissionsDTO : columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO)) {
|
||||
columnPermissionsDTO.getWhiteListUser();
|
||||
List<Long> userIdList = new Gson().fromJson(columnPermissionsDTO.getWhiteListUser(), new TypeToken<List<Long>>() {
|
||||
}.getType());
|
||||
if (CollectionUtils.isEmpty(userIdList) || !userIdList.contains(userId)) {
|
||||
roleColumnPermissionsDTOS.add(columnPermissionsDTO);
|
||||
DataSetColumnPermissionsDTO request = new DataSetColumnPermissionsDTO();
|
||||
request.setDatasetId(datasetId);
|
||||
request.setAuthTargetType("role");
|
||||
List<Item> items = (List<Item>)columnPermissionService.authObjs(request);
|
||||
roleIds = roleIds.stream().filter(id -> {return items.stream().map(Item::getId).collect(Collectors.toList()).contains(id);}).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(roleIds)){
|
||||
dataSetColumnPermissionsDTO.setAuthTargetIds(roleIds);
|
||||
dataSetColumnPermissionsDTO.setAuthTargetType("role");
|
||||
List<DataSetColumnPermissionsDTO> roleColumnPermissionsDTOS = new ArrayList<>();
|
||||
for (DataSetColumnPermissionsDTO columnPermissionsDTO : columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO)) {
|
||||
columnPermissionsDTO.getWhiteListUser();
|
||||
List<Long> userIdList = new Gson().fromJson(columnPermissionsDTO.getWhiteListUser(), new TypeToken<List<Long>>() {
|
||||
}.getType());
|
||||
if (CollectionUtils.isEmpty(userIdList) || !userIdList.contains(userId)) {
|
||||
roleColumnPermissionsDTOS.add(columnPermissionsDTO);
|
||||
}
|
||||
}
|
||||
datasetColumnPermissions.addAll(roleColumnPermissionsDTOS);
|
||||
}
|
||||
datasetColumnPermissions.addAll(roleColumnPermissionsDTOS);
|
||||
}
|
||||
|
||||
if (deptId != null) {
|
||||
dataSetColumnPermissionsDTO.setAuthTargetIds(Collections.singletonList(deptId));
|
||||
dataSetColumnPermissionsDTO.setAuthTargetType("dept");
|
||||
List<DataSetColumnPermissionsDTO> deptColumnPermissionsDTOS = new ArrayList<>();
|
||||
for (DataSetColumnPermissionsDTO columnPermissionsDTO : columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO)) {
|
||||
List<Long> userIdList = new Gson().fromJson(columnPermissionsDTO.getWhiteListUser(), new TypeToken<List<Long>>() {
|
||||
}.getType());
|
||||
if (CollectionUtils.isEmpty(userIdList) || !userIdList.contains(userId)) {
|
||||
deptColumnPermissionsDTOS.add(columnPermissionsDTO);
|
||||
DataSetColumnPermissionsDTO request = new DataSetColumnPermissionsDTO();
|
||||
request.setDatasetId(datasetId);
|
||||
request.setAuthTargetType("dept");
|
||||
List<Item> items = (List<Item>)columnPermissionService.authObjs(request);
|
||||
if(items.stream().map(Item::getId).collect(Collectors.toList()).contains(deptId)){
|
||||
dataSetColumnPermissionsDTO.setAuthTargetIds(Collections.singletonList(deptId));
|
||||
dataSetColumnPermissionsDTO.setAuthTargetType("dept");
|
||||
List<DataSetColumnPermissionsDTO> deptColumnPermissionsDTOS = new ArrayList<>();
|
||||
for (DataSetColumnPermissionsDTO columnPermissionsDTO : columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO)) {
|
||||
List<Long> userIdList = new Gson().fromJson(columnPermissionsDTO.getWhiteListUser(), new TypeToken<List<Long>>() {
|
||||
}.getType());
|
||||
if (CollectionUtils.isEmpty(userIdList) || !userIdList.contains(userId)) {
|
||||
deptColumnPermissionsDTOS.add(columnPermissionsDTO);
|
||||
}
|
||||
}
|
||||
datasetColumnPermissions.addAll(deptColumnPermissionsDTOS);
|
||||
}
|
||||
datasetColumnPermissions.addAll(deptColumnPermissionsDTOS);
|
||||
}
|
||||
|
||||
return datasetColumnPermissions;
|
||||
}
|
||||
|
||||
|
@ -73,28 +73,7 @@ dataease.sqlinjection.whitelists=/dataset/table/sqlPreview,/dataset/table/update
|
||||
server.compression.enabled=true
|
||||
server.compression.mime-types=application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
|
||||
server.compression.min-response-size=1024
|
||||
#\u4E0B\u9762\u7684\u914D\u7F6E\u65B0\u589E\u5230/opt/dataease/conf/dataease/properties
|
||||
#\u7F13\u5B58\u7C7B\u578B
|
||||
##spring.cache.type=redis
|
||||
#spring.cache.type=ehcache
|
||||
#redis\u516C\u5171\u914D\u7F6E
|
||||
#spring.redis.timeout=10000
|
||||
#spring.redis.lettuce.pool.max-active=8
|
||||
#spring.redis.lettuce.pool.max-wait=-1
|
||||
#spring.redis.lettuce.pool.max-idle=8
|
||||
#\u5355\u673A\u6A21\u5F0Fredis\u914D\u7F6E
|
||||
#spring.redis.database=0
|
||||
#spring.redis.host=192.168.0.110
|
||||
#spring.redis.port=6379
|
||||
#spring.redis.password=DataEase_ZNB@REDIS
|
||||
#\u54E8\u5175\u6A21\u5F0Fredis\u914D\u7F6E
|
||||
#spring.redis.sentinel.master=mymaster
|
||||
#spring.redis.sentinel.nodes=192.168.0.110:26379,192.168.0.110:26380,192.168.0.110:26381
|
||||
#spring.redis.sentinel.password=
|
||||
#cluster\u6A21\u5F0Fredis\u914D\u7F6E
|
||||
#spring.redis.cluster.nodes=192.168.0.110:7001,192.168.0.110:7002,192.168.0.110:7003,192.168.0.110:7004,192.168.0.110:7005,192.168.0.110:7006
|
||||
#spring.redis.cluster.max-redirects=3
|
||||
#spring.redis.password=DataEase_ZNB@REDIS
|
||||
|
||||
server.servlet.context-parameters.configurationStrategy=SYSTEM_PROPERTIES
|
||||
server.servlet.session.cookie.http-only=true
|
||||
server.servlet.session.tracking-modes=cookie
|
||||
|
@ -462,11 +462,7 @@ export default {
|
||||
|
||||
tabClick() {
|
||||
if (this.tabActive === 'dataPreview') {
|
||||
const reload = localStorage.getItem('reloadDsData')
|
||||
if (reload === 'true') {
|
||||
localStorage.setItem('reloadDsData', 'false')
|
||||
this.initTable(this.param.id)
|
||||
}
|
||||
this.initTable(this.param.id)
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user