You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/01/31 14:15:29 UTC

[shardingsphere] branch master updated: fill SchemaPrivilege (#9236)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 4551b4d  fill SchemaPrivilege (#9236)
4551b4d is described below

commit 4551b4d8db7f955abd43140ae323e0c1e736a9ca
Author: Juan Pan(Trista) <pa...@apache.org>
AuthorDate: Sun Jan 31 22:14:58 2021 +0800

    fill SchemaPrivilege (#9236)
    
    * fill SchemaPrivilege
    
    * revert
    
    * typo
---
 .../shardingsphere/infra/auth/SchemaPrivilege.java | 27 +++++++++++++++++++++-
 .../src/main/resources/conf/server.yaml            |  3 +--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/SchemaPrivilege.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/SchemaPrivilege.java
index 68b1b8c..762b50d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/SchemaPrivilege.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/SchemaPrivilege.java
@@ -17,9 +17,34 @@
 
 package org.apache.shardingsphere.infra.auth;
 
+import lombok.Getter;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 /**
  * Schema privilege.
  */
+@Getter
 public final class SchemaPrivilege {
-
+    
+    private final Map<String, TablePrivilege> tablePrivileges = new LinkedHashMap<>();
+    
+    /**
+     * Has privileges.
+     *
+     * @param table table
+     * @param privileges privileges
+     * @return has privileges or not
+     */
+    public boolean hasPrivileges(final String table, final Collection<PrivilegeType> privileges) {
+        if (!tablePrivileges.containsKey(table)) {
+            return false;
+        }
+        if (tablePrivileges.containsKey("*")) {
+            return tablePrivileges.get("*").hasPrivileges(privileges);
+        }
+        return tablePrivileges.get(table).hasPrivileges(privileges);
+    }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
index a6830a6..1719956 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
@@ -36,7 +36,6 @@
 #authentication:
 #  users:
 #    root:
-#      hostname: 127.0.01
 #      password: root
 #    sharding:
 #      password: sharding
@@ -59,6 +58,6 @@
 #  proxy-opentracing-enabled: false
 #  proxy-hint-enabled: false
 #  query-with-cipher-column: true
-#  sql-show: false
+#  sql-show: true
 #  check-table-metadata-enabled: false
 #  lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock