【问题标题】:Is there a way to combine RBAC with LDAP in Apache Airflow?有没有办法在 Apache Airflow 中将 RBAC 与 LDAP 结合起来?
【发布时间】:2020-03-26 03:25:21
【问题描述】:

我正在尝试在 Airflow 中对 Active Directory 中的用户实施精细权限。是否可以通过LDAP 向 Active Directory 进行身份验证并通过RBAC 实施安全/权限(通过将 RBAC 角色映射到 AD 组/用户)?我了解 LDAP 集成提供了通过过滤器配置(LDAP Documentation) 将组映射到超级用户和数据分析器的能力。但我对通过 RBAC 提供的更精细的控制很感兴趣。

我已经能够将我的 Active Directory 连接到 Airflow。但是,当我尝试添加 RBAC 时,我无法登录。RBAC 配置似乎覆盖了 LDAP 配置。有没有人能够做到这一点?

【问题讨论】:

    标签: python ldap airflow rbac


    【解决方案1】:

    你需要在airflow根文件夹中添加webserver_config.py,你应该在其中设置:

    # Uncomment this line
    flask_appbuilder.security.manager import AUTH_LDAP
    ....
    AUTH_TYPE = AUTH_LDAP
    AUTH_LDAP_SERVER = "ldap://localhost:389"
    
    AUTH_LDAP_SEARCH=ou=users,dc=example,dc=org
    AUTH_LDAP_BIND_USER=cn=user,ou=app,dc=example,dc=org
    AUTH_LDAP_BIND_PASSWORD=pwd
    

    这里https://airflow.apache.org/docs/stable/_modules/airflow/configuration.html可以看到启用RBAC后,webserver设置被覆盖

    WEBSERVER_CONFIG = AIRFLOW_HOME + '/webserver_config.py'
    
    if conf.getboolean('webserver', 'rbac'):
        if not os.path.isfile(WEBSERVER_CONFIG):
            log.info('Creating new FAB webserver config file in: %s', WEBSERVER_CONFIG)
            DEFAULT_WEBSERVER_CONFIG, _ = _read_default_config_file('default_webserver_config.py')
            with open(WEBSERVER_CONFIG, 'w') as file:
                file.write(DEFAULT_WEBSERVER_CONFIG)
    

    【讨论】:

    • 我使用 1.10.10,无法使用 Traceback(最近一次调用最后一次):文件“/home/airflow/.local/lib/python3.6/site-packages/flask_appbuilder/security/manager. py",第 874 行,在 auth_user_ldap import ldap ModuleNotFoundError: No module named 'ldap'
    • @geosmart 所以你必须安装 ldap pip install apache-airflow[ldap] && pip install python-ldap
    • @user2355668 python-ldap 还是 python3-ldap?
    • 我使用了 python-ldap。 python3-ldap 非常旧 - 最后发布日期为 2015 年 5 月 28 日,@geosmart
    猜你喜欢
    • 2011-08-24
    • 2015-04-05
    • 2013-12-28
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    • 2013-09-15
    • 2017-12-14
    • 2021-11-03
    相关资源
    最近更新 更多