简体   繁体   English

有没有人尝试在 Apache Superset 中实现多租户

[英]Is anyone try to implement Multi-Tenancy in Apache Superset

I tried by cloning from the Github project, but it's not worked for me.我尝试从 Github 项目克隆,但它对我不起作用。 Is any other way to achieve multi-tenancy in Apache superset.在 Apache 超集中实现多租户的任何其他方式。 I tried from this source https://github.com/apache/incubator-superset/pull/3729/files/5a063f37d77efc0d4a50ba8406a62e8eee4964ed .我从这个来源尝试了https://github.com/apache/incubator-superset/pull/3729/files/5a063f37d77efc0d4a50ba8406a62e8eee4964ed But I didn't achieve multi-tenancy.但我没有实现多租户。 I got stuck with these errors.我被这些错误困住了。

Traceback (most recent call last):
  File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\myfolder\my-superset\venv\Scripts\flask.exe\__main__.py", line 9, in <module>
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask\cli.py", line 967, in main
    cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask\cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "d:\myfolder\my-superset\venv\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask\cli.py", line 425, in decorator
    with __ctx.ensure_object(ScriptInfo).load_app().app_context():
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask\cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "D:\myfolder\my-superset\Apache-superset-multi_tenancy_new\superset\__init__.py", line 22, in <module>
    from superset.multi_tenant import MultiTenantSecurityManager
  File "D:\myfolder\my-superset\Apache-superset-multi_tenancy_new\superset\multi_tenant.py", line 9, in <module>
    class MultiTenantUser(User):
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask_sqlalchemy\model.py", line 67, in __init__
    super(NameMetaMixin, cls).__init__(name, bases, d)
  File "d:\myfolder\my-superset\venv\lib\site-packages\flask_sqlalchemy\model.py", line 121, in __init__
    super(BindMetaMixin, cls).__init__(name, bases, d)
  File "d:\myfolder\my-superset\venv\lib\site-packages\sqlalchemy\ext\declarative\api.py", line 75, in __init__
    _as_declarative(cls, classname, cls.__dict__)
  File "d:\myfolder\my-superset\venv\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 131, in _as_declarative
    _MapperConfig.setup_mapping(cls, classname, dict_)
  File "d:\myfolder\my-superset\venv\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 160, in setup_mapping
    cfg_cls(cls_, classname, dict_)
  File "d:\myfolder\my-superset\venv\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 192, in __init__
    self._setup_inheritance()
  File "d:\myfolder\my-superset\venv\lib\site-packages\sqlalchemy\ext\declarative\base.py", line 601, in _setup_inheritance
    "Can't place __table_args__ on an inherited class "
sqlalchemy.exc.ArgumentError: Can't place __table_args__ on an inherited class with no table.

I am unable to find any solution regarding this error.我无法找到有关此错误的任何解决方案。

There's a new feature called "Row Level Security (RLS).有一个名为“行级安全性 (RLS)”的新功能。

https://github.com/apache/incubator-superset/pull/8699 https://github.com/apache/incubator-superset/pull/8699

It's was merged in release 0.36 but had a bug, so was excluded last minute and shifted to 0.37.它在 0.36 版中合并,但有一个错误,因此在最后一分钟被排除并转移到 0.37。 It's disabled by default and can be enabled in the config file superset_config.py :默认情况下它是禁用的,可以在配置文件superset_config.py中启用:

ENABLE_ROW_LEVEL_SECURITY = True ENABLE_ROW_LEVEL_SECURITY = 真

You'll find some menu item in "security" which will allow you to add custom filters that will be added to queries.您会在“安全性”中找到一些菜单项,允许您添加将添加到查询中的自定义过滤器。 It's configured by datasource and filters can be dependant on user roles.它由数据源配置,过滤器可以依赖于用户角色。 SQL is free and thus very flexible. SQL 是免费的,因此非常灵活。 So the main tenant logic needs to be applied to your tenant model in the SQL.所以主租户逻辑需要应用到SQL中你的租户model。

You can also use JINJA scripting, but you're limited to supersets own variables here as self defined vars will live on a different machine (UI vs backend aka celery worker).您也可以使用 JINJA 脚本,但在这里您仅限于超集自己的变量,因为自定义变量将存在于不同的机器上(UI 与后端,即 celery 工作人员)。

The feature is used in different production environments already (this info is from the dev list).该功能已经在不同的生产环境中使用(此信息来自开发列表)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM