john-bodley commented on a change in pull request #15184:
URL: https://github.com/apache/superset/pull/15184#discussion_r660139948



##########
File path: superset/connectors/connector_registry.py
##########
@@ -99,6 +100,41 @@ def get_datasource_by_id(  # pylint: 
disable=too-many-arguments
                 pass
         raise NoResultFound(_("Datasource id not found: %(id)s", 
id=datasource_id))
 
+    @classmethod
+    def get_user_datasources(cls, session: Session) -> List["BaseDatasource"]:
+        from superset import security_manager
+
+        # collect datasources which the user has explicit permissions to
+        user_perms = security_manager.user_view_menu_names("datasource_access")
+        schema_perms = security_manager.user_view_menu_names("schema_access")
+        user_datasources = set()
+        for datasource_class in ConnectorRegistry.sources.values():
+            user_datasources.update(
+                session.query(datasource_class)

Review comment:
       @betodealmeida if the `get_datasources_accessible_by_user` method isn't 
ideal, then I think the alternatively would be to move the 
`get_user_datasources` method to the security manager so deployments can 
overwrite the logic if necessary.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to