4

I'm running airflow v 1.9.0. I am trying to get some form of authentication working but have so far failed to get github auth and password auth working. The password auth feels like it should be pretty straight forward and I'm hoping someone can point me in the right direction. My airflow.cfg has the following

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

Following the instructions here https://airflow.incubator.apache.org/security.html#password I've logged into my airflow web server and run the following interactive python to try to create a user which gives me an error

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

Going through the web UI to create a user I just get an exception. Here is the end of the exception. https://www.dropbox.com/s/7cxwi6hdde61wnb/Screenshot%202018-02-21%2013.52.16.png?dl=0

Any tips appreciated.
Thanks!

Guido Pepper
  • 171
  • 2
  • 8

2 Answers2

3

You need to use <1.2.0 version of sqlalchemy ('sqlalchemy>=1.1.15, <1.2.0',) or use "_password".

Changing version of sqlalchemy is better.

Vinay
  • 31
  • 1
2

As mentioned here, using the _set_password method worked for me when I had the same error:

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()
mgig
  • 2,395
  • 4
  • 21
  • 36