Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #7929] Add some request codes to the permission verification for the admin role #7930

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public class Permission {
ADMIN_CODE.add(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP);
// DELETE_SUBSCRIPTIONGROUP
ADMIN_CODE.add(RequestCode.DELETE_SUBSCRIPTIONGROUP);
// UPDATE_AND_CREATE_STATIC_TOPIC
ADMIN_CODE.add(RequestCode.UPDATE_AND_CREATE_STATIC_TOPIC);
// UPDATE_AND_CREATE_ACL_CONFIG
ADMIN_CODE.add(RequestCode.UPDATE_AND_CREATE_ACL_CONFIG);
// DELETE_ACL_CONFIG
ADMIN_CODE.add(RequestCode.DELETE_ACL_CONFIG);
// GET_BROKER_CLUSTER_ACL_INFO
ADMIN_CODE.add(RequestCode.GET_BROKER_CLUSTER_ACL_INFO);
}

public static boolean checkPermission(byte neededPerm, byte ownedPerm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Map;
import java.util.Set;
import org.apache.rocketmq.acl.plain.PlainAccessResource;
import org.apache.rocketmq.remoting.protocol.RequestCode;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -141,11 +142,15 @@ public void setTopicPermTest() {
@Test
public void checkAdminCodeTest() {
Set<Integer> code = new HashSet<>();
code.add(17);
code.add(25);
code.add(215);
code.add(200);
code.add(207);
code.add(RequestCode.UPDATE_AND_CREATE_TOPIC);
code.add(RequestCode.UPDATE_BROKER_CONFIG);
code.add(RequestCode.DELETE_TOPIC_IN_BROKER);
code.add(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP);
code.add(RequestCode.DELETE_SUBSCRIPTIONGROUP);
code.add(RequestCode.UPDATE_AND_CREATE_STATIC_TOPIC);
code.add(RequestCode.UPDATE_AND_CREATE_ACL_CONFIG);
code.add(RequestCode.DELETE_ACL_CONFIG);
code.add(RequestCode.GET_BROKER_CLUSTER_ACL_INFO);

for (int i = 0; i < 400; i++) {
boolean boo = Permission.needAdminPerm(i);
Expand Down
Loading