Created
October 3, 2017 08:18
-
-
Save dinigo/c86c66b31c44d8f85571bb0e8d2106ca to your computer and use it in GitHub Desktop.
Add user to Airflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# This little script creates users in an airflow instance so it can be open to the public. | |
# It gets the password in plain text so be careful where you run it. | |
# You can properly invoke the script as follows: | |
# ./add_user.py <username> <[email protected]> <secretpassword> | |
import airflow, sys | |
from airflow import models, settings | |
from airflow.contrib.auth.backends.password_auth import PasswordUser | |
user = PasswordUser(models.User()) | |
user.username = sys.argv[1] | |
user.email = sys.argv[2] | |
user.password = sys.argv[3] | |
session = settings.Session() | |
session.add(user) | |
session.commit() | |
session.close() | |
exit() |
Use user._set_password
instead of user.password
- https://stackoverflow.com/questions/48075826/airflow-authentication-setups-fails-with-attributeerror-cant-set-attribute
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of using a password in plain text, is there a way to pass a hash?