You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/04/08 06:48:08 UTC

[GitHub] [shardingsphere] totalo opened a new pull request #9987: Load users and privileges from SQLServer

totalo opened a new pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987


   Fixes #9855.
   
   Changes proposed in this pull request:
   - Load users and privileges from SQLServer
   


-- 
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.

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



[GitHub] [shardingsphere] totalo commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-816665288


   > Hi @totalo ,
   > 
   > I know the privilege system of SQLServer is large and complicated, but we can firstly fill some necessary privileges of `Server level`, `DB` and `table`.
   > 
   > [principals-database-engine](https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine?view=sql-server-ver15) and[Guide to SQL Server Permissions](https://blog.netwrix.com/2020/10/16/guide-to-sql-server-permissions/) give us a brief introduction on SQLserver's privileges. We can learn that there are two layers of principals, i.e., `Server-level` and `Database-level`.
   > 
   > I assume that
   > 
   > * `Server-level` privileges is bound to be mapped to our `AdministrativePrivileges` and `DatabasePrivileges`
   > * `DB-lever` privileges belong to `globalPrivileges` of `DatabasePrivileges` or `specificPrivileges`
   > * Still we have table some privileges putting into `TablePrivileges`
   > 
   > Also, there are many different specific privileges on `server-level` and `db-lever`, right? You can pick up the main ones as the first step.
   > 
   > This is just my opinion, welcome your any reply.
   
   Yes, I think so too. I have already looked at principals-database-engine when searching for information. But at the time, my grasp of the direction was not very clear. Thank you for providing me with these three directions, please give me some time, I will study it, and then revise this PR.


-- 
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.

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



[GitHub] [shardingsphere] totalo commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-816663824


   > [principals-database-engine](https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine?view=sql-server-ver15)
   
   Yes, I think so too. I have already looked at principals-database-engine when searching for information. Thank you for providing me with these three directions, please give me some time, I will study it, and then modify this pr


-- 
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.

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



[GitHub] [shardingsphere] totalo commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-818664189


   > @totalo Take it easy, there are plenty of time for you to learn more and make this PR perfect.
   
   Hello, I tried to fix a version, please review it.


-- 
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.

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



[GitHub] [shardingsphere] tristaZero commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-816383392


   @totalo Sorry that there are some conflict files to fix. But take it easy, since it is about package adjustments, it is not hard to fix.


-- 
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.

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



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#discussion_r612972756



##########
File path: shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/ShardingSpherePrivileges.java
##########
@@ -23,28 +23,28 @@
  * ShardingSphere Privileges.
  */
 public interface ShardingSpherePrivileges {
-    
+
     /**
      * Set super privilege.
      */
     void setSuperPrivilege();
-    

Review comment:
       Hi @totalo,
   
   Thanks for your efforts. It looks much better.
   Just one issue here.  There is no necessary changes in this file, I guess,  could you  revert it?




-- 
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.

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



[GitHub] [shardingsphere] totalo removed a comment on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo removed a comment on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-816663824


   > [principals-database-engine](https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine?view=sql-server-ver15)
   
   Yes, I think so too. I have already looked at principals-database-engine when searching for information. Thank you for providing me with these three directions, please give me some time, I will study it, and then modify this pr


-- 
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.

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



[GitHub] [shardingsphere] totalo commented on a change in pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on a change in pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#discussion_r613092242



##########
File path: shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/ShardingSpherePrivileges.java
##########
@@ -23,28 +23,28 @@
  * ShardingSphere Privileges.
  */
 public interface ShardingSpherePrivileges {
-    
+
     /**
      * Set super privilege.
      */
     void setSuperPrivilege();
-    

Review comment:
       ok~




-- 
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.

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



[GitHub] [shardingsphere] totalo commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-819951749


   /ci


-- 
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.

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



[GitHub] [shardingsphere] tristaZero commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-817469567


   @totalo Take it easy, there are plenty of time for you to learn more and make this PR perfect.


-- 
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.

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



[GitHub] [shardingsphere] totalo edited a comment on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo edited a comment on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-819951749


   /CI


-- 
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.

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



[GitHub] [shardingsphere] totalo closed pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo closed pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987


   


-- 
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.

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



[GitHub] [shardingsphere] totalo removed a comment on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo removed a comment on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-819951749


   /CI


-- 
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.

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



[GitHub] [shardingsphere] totalo commented on pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#issuecomment-817645950


   I will submit again when the modification is completed


-- 
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.

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



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#discussion_r609413547



##########
File path: shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/dialect/SQLServerPrivilegeLoader.java
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.shardingsphere.authority.loader.storage.impl.dialect;
+
+import org.apache.shardingsphere.authority.loader.storage.impl.StoragePrivilegeLoader;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
+import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.database.SchemaPrivileges;
+import org.apache.shardingsphere.authority.model.database.TablePrivileges;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * SQLServer privilege loader.
+ */
+public final class SQLServerPrivilegeLoader implements StoragePrivilegeLoader {
+
+    private static final String TABLE_PRIVILEGE_SQL =

Review comment:
       So is there any privilege having nothing to do with `Table`? E.g., `BACKUP DATABASE,`BACKUP LOG`, `CREATE DATABASE`?




-- 
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.

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



[GitHub] [shardingsphere] totalo commented on a change in pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
totalo commented on a change in pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987#discussion_r609442539



##########
File path: shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/dialect/SQLServerPrivilegeLoader.java
##########
@@ -0,0 +1,147 @@
+/*
+ * 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.shardingsphere.authority.loader.storage.impl.dialect;
+
+import org.apache.shardingsphere.authority.loader.storage.impl.StoragePrivilegeLoader;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
+import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.database.SchemaPrivileges;
+import org.apache.shardingsphere.authority.model.database.TablePrivileges;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * SQLServer privilege loader.
+ */
+public final class SQLServerPrivilegeLoader implements StoragePrivilegeLoader {
+
+    private static final String TABLE_PRIVILEGE_SQL =

Review comment:
       Yes, it has, I didn’t find the relevant information at first, now I have added it




-- 
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.

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



[GitHub] [shardingsphere] tristaZero merged pull request #9987: Load users and privileges from SQLServer

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #9987:
URL: https://github.com/apache/shardingsphere/pull/9987


   


-- 
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.

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