diable operate admin user

This commit is contained in:
许晓东
2021-09-03 15:33:05 +08:00
parent f2ee4680d4
commit b347566dad
4 changed files with 27 additions and 4 deletions

3
.gitignore vendored
View File

@@ -58,3 +58,6 @@ pnpm-debug.log*
*.sln
*.sw?
/ui/node
/logs
/LOGGING_HOME_IS_UNDEFINED
*.log

View File

@@ -88,9 +88,15 @@ public class AclServiceImpl implements AclService, SmartInitializingSingleton {
List<AclBinding> aclBindingList = entry.isNull() ? aclConsole.getAclList(null) : aclConsole.getAclList(entry);
List<AclEntry> entryList = aclBindingList.stream().map(x -> AclEntry.valueOf(x)).collect(Collectors.toList());
Map<String, List<AclEntry>> entryMap = entryList.stream().collect(Collectors.groupingBy(AclEntry::getPrincipal));
Map<String, Map<String, List<AclEntry>>> resultMap = new HashMap<>();
Map<String, Object> resultMap = new HashMap<>();
entryMap.forEach((k, v) -> {
Map<String, List<AclEntry>> map = v.stream().collect(Collectors.groupingBy(e -> e.getResourceType() + "#" + e.getName()));
if (k.equals(kafkaConfig.getAdminUsername())) {
Map<String, Object> map2 = new HashMap<>(map);
Map<String, Object> userMap = new HashMap<>();
userMap.put("role", "admin");
map2.put("USER", userMap);
}
resultMap.put(k, map);
});
if (entry.isNull() || StringUtils.isNotBlank(entry.getPrincipal())) {
@@ -98,7 +104,15 @@ public class AclServiceImpl implements AclService, SmartInitializingSingleton {
detailList.values().forEach(u -> {
if (!resultMap.containsKey(u.name()) && !u.credentialInfos().isEmpty()) {
resultMap.put(u.name(), Collections.emptyMap());
if (!u.name().equals(kafkaConfig.getAdminUsername())) {
resultMap.put(u.name(), Collections.emptyMap());
} else {
Map<String, Object> map2 = new HashMap<>();
Map<String, Object> userMap = new HashMap<>();
userMap.put("role", "admin");
map2.put("USER", userMap);
resultMap.put(u.name(), map2);
}
}
});
}

View File

@@ -28,7 +28,8 @@ const routes = [
];
const router = new VueRouter({
mode: "history",
// mode: "history",
mode: "hash",
base: process.env.BASE_URL,
routes,
});

View File

@@ -53,7 +53,11 @@
></UpdateUser>
</div>
<a-table :columns="columns" :data-source="data" bordered>
<a slot="operation" slot-scope="record">
<a
slot="operation"
slot-scope="record"
v-show="!record.user || record.user.role != 'admin'"
>
<a-popconfirm
:title="'删除用户: ' + record.username + '及相关权限?'"
ok-text="确认"
@@ -241,6 +245,7 @@ function getAclList(data, requestParameters) {
username: k,
topicList: topicList.join(", "),
groupList: groupList.join(", "),
user: response.data.map[k]["USER"],
});
}
});