Skip to content

Commit

Permalink
[INLONG-7946][Manager] Add user authentication when bind clusterTag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fuweng11 committed May 1, 2023
1 parent 7214e0b commit 216b9b4
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -664,6 +664,8 @@ public Boolean bindTag(BindTagRequest request, String operator) {
if (CollectionUtils.isNotEmpty(request.getBindClusters())) {
request.getBindClusters().forEach(id -> {
InlongClusterEntity entity = clusterMapper.selectById(id);
userService.checkUser(entity.getInCharges(), operator,
"Current user does not have permission to bind or unbind cluster tag");
Set<String> tagSet = Sets.newHashSet(entity.getClusterTags().split(InlongConstants.COMMA));
tagSet.add(clusterTag);
String updateTags = Joiner.on(",").join(tagSet);
Expand All @@ -681,6 +683,10 @@ public Boolean bindTag(BindTagRequest request, String operator) {
if (CollectionUtils.isNotEmpty(request.getUnbindClusters())) {
request.getUnbindClusters().forEach(id -> {
InlongClusterEntity entity = clusterMapper.selectById(id);
String errMsg = String.format(
"Current user does not have permission to bind or unbind cluster tag for cluster by id=%s, name=%s",
entity.getId(), entity.getName());
userService.checkUser(entity.getInCharges(), operator, errMsg);
this.removeClusterTag(entity, clusterTag, operator);
});
}
Expand All @@ -697,6 +703,10 @@ public Boolean bindTag(BindTagRequest request, UserInfo opInfo) {
if (CollectionUtils.isNotEmpty(request.getBindClusters())) {
request.getBindClusters().forEach(id -> {
InlongClusterEntity entity = clusterMapper.selectById(id);
String errMsg = String.format(
"Current user does not have permission to bind or unbind cluster tag for cluster by id=%s, name=%s",
entity.getId(), entity.getName());
userService.checkUser(entity.getInCharges(), opInfo.getName(), errMsg);
Set<String> tagSet = Sets.newHashSet(entity.getClusterTags().split(InlongConstants.COMMA));
tagSet.add(request.getClusterTag());
String updateTags = Joiner.on(",").join(tagSet);
Expand All @@ -713,6 +723,10 @@ public Boolean bindTag(BindTagRequest request, UserInfo opInfo) {
if (CollectionUtils.isNotEmpty(request.getUnbindClusters())) {
request.getUnbindClusters().forEach(id -> {
InlongClusterEntity entity = clusterMapper.selectById(id);
String errMsg = String.format(
"Current user does not have permission to bind or unbind cluster tag for cluster by id=%s, name=%s",
entity.getId(), entity.getName());
userService.checkUser(entity.getInCharges(), opInfo.getName(), errMsg);
Set<String> tagSet = Sets.newHashSet(entity.getClusterTags().split(InlongConstants.COMMA));
tagSet.remove(request.getClusterTag());
String updateTags = Joiner.on(",").join(tagSet);
Expand Down

0 comments on commit 216b9b4

Please sign in to comment.