Skip to content

Instantly share code, notes, and snippets.

@dinigo
Created October 3, 2017 08:18
Show Gist options
  • Save dinigo/c86c66b31c44d8f85571bb0e8d2106ca to your computer and use it in GitHub Desktop.
Save dinigo/c86c66b31c44d8f85571bb0e8d2106ca to your computer and use it in GitHub Desktop.

Revisions

  1. dinigo created this gist Oct 3, 2017.
    19 changes: 19 additions & 0 deletions add_user.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/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()