Skip to content

Instantly share code, notes, and snippets.

@dinigo
Created October 3, 2017 08:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dinigo/c86c66b31c44d8f85571bb0e8d2106ca to your computer and use it in GitHub Desktop.
Save dinigo/c86c66b31c44d8f85571bb0e8d2106ca to your computer and use it in GitHub Desktop.
Add user to Airflow
#!/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> <user@email.com> <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()
@srikrishnavamsi
Copy link

srikrishnavamsi commented Oct 17, 2018

Instead of using a password in plain text, is there a way to pass a hash?

@Valian
Copy link

Valian commented Oct 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment