You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/12/07 11:49:16 UTC

[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #11076: update(qos): support anonymous access.

AlbumenJ commented on code in PR #11076:
URL: https://github.com/apache/dubbo/pull/11076#discussion_r1042107492


##########
dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultAnonymousAccessPermissionChecker.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.qos.command;
+
+import org.apache.dubbo.qos.command.annotation.Cmd;
+
+public class DefaultAnonymousAccessPermissionChecker implements PermissionChecker {
+    public static final DefaultAnonymousAccessPermissionChecker INSTANCE = new DefaultAnonymousAccessPermissionChecker();
+
+    @Override
+    public boolean access(CommandContext commandContext, Cmd.PermissionLevel defaultCmdRequiredPermissionLevel) {
+        return commandContext.hasPermission(defaultCmdRequiredPermissionLevel);
+    }
+}

Review Comment:
   Is it really necessary to create this class separately.



##########
dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/annotation/Cmd.java:
##########
@@ -55,4 +58,57 @@
      * @return command order in help
      */
     int sort() default 0;
+
+    /**
+     * Command required access permission level
+     *
+     * @return command permission level
+     */
+    PermissionLevel requiredPermissionLevel() default PermissionLevel.PROTECTED;
+
+    enum PermissionLevel {
+        /**
+         * the lowest permission level, can access with
+         * anonymousAccessPermissionLevel=PUBLIC / anonymousAccessPermissionLevel=1 or higher
+         */
+        PUBLIC(1),
+        /**
+         * the middle permission level, default permission for each cmd
+         */
+        PROTECTED(2),
+        /**
+         * the highest permission level, suppose only the localhost can access this command
+         */
+        PRIVATE(3),
+
+        /**
+         * It is the reserved default anonymous permission level, can not access any command
+         */
+        NONE(Integer.MIN_VALUE),
+
+        ;
+        private final int level;
+

Review Comment:
   Move out as a public class



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org