Airflow基本身份验证 - 无法创建用户

时间:2018-02-21 23:16:36

标签: airflow

我正在运行airflow v 1.9.0。我试图获得某种形式的身份验证工作,但迄今为止未能获得github身份验证和密码身份验证工作。密码认证感觉应该是非常直接的,我希望有人可以指出我正确的方向。我的airflow.cfg有以下内容

[webserver]
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

按照此处的说明https://airflow.incubator.apache.org/security.html#password我已登录到我的气流网络服务器并运行以下交互式python尝试创建一个给我错误的用户

airflow@airflow-web-66fbccc84c-vmqbp:~$ python3
Python 3.6.4 (default, Feb 15 2018, 13:07:07)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import airflow
>>> from airflow import models, settings
>>> from airflow.contrib.auth.backends.password_auth import PasswordUser
>>> user = PasswordUser(models.User())
>>> user.username = 'admin'
>>> user.password = 'airflowWTF'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 873, in __set__
        raise AttributeError("can't set attribute")
        AttributeError: can't set attribute

通过Web UI创建用户我只是得到一个例外。这是例外的结束。 https://www.dropbox.com/s/7cxwi6hdde61wnb/Screenshot%202018-02-21%2013.52.16.png?dl=0

任何提示赞赏。
谢谢!

2 个答案:

答案 0 :(得分:3)

您需要使用&lt; 1.2.0版本的sqlalchemy(&#39; sqlalchemy&gt; = 1.1.15,&lt; 1.2.0&#39;,)或使用&#34; _password&#34;。

更改sqlalchemy的版本更好。

答案 1 :(得分:1)

正如前面提到的here,当我遇到同样的错误时,使用import airflow from airflow import models, settings from airflow.contrib.auth.backends.password_auth import PasswordUser user = PasswordUser(models.User()) user.username = 'new_user_name' user.email = 'new_user_email@example.com' user._set_password = 'set_the_password'.encode('utf8') session = settings.Session() session.add(user) session.commit() session.close() 方法对我有用:

import java.util.Arrays;

class Progression {

    public static String arithmeticSequenceElements(int first, int step, 
    long total) {
    int[] intArr;
    intArr = new int [(int)total];
    intArr[0] = first;
    int i = 1;
    while(i<total){
      intArr[i] = intArr[i-1] + step;
      i++;
    }
    return Arrays.toString(intArr);
  }

}