airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [airflow] ddelange edited a comment on issue #5056: [AIRFLOW-4259] Move remaining models out of
Date Tue, 12 Nov 2019 09:24:11 GMT
ddelange edited a comment on issue #5056: [AIRFLOW-4259] Move remaining models out of
   Hey @BasPH @Fokko @ashb, why was `` [removed](
in `master`?
   It is still used by multiple auth backends on `master` (there's also no mention of this
removal in ``):
   How would I now on `master` for create an API user for instance?
   Below workflow will work on 1.10 but will fail on master:
   auth_backend = airflow.contrib.auth.backends.password_auth
   upon startup I now use models.User to create a PasswordUser:
   import os
   from airflow.contrib.auth.backends.password_auth import PasswordUser
   from airflow import models
   from airflow.settings import Session
   def delete_users(session, username):
       """Delete all users with username"""
       query = session.query(models.User)
       to_delete = [ for user in query.all() if user.username == username]
       for user_id in to_delete:
       if to_delete:
   def create_user(session, username, password):
       """Create a new user with password"""
       user = PasswordUser(models.User())
       user.username = username = "REST_API"
       user.password = password
   def set_or_overwrite_api_user():
       """Add REST API user (BasicAuth), or delete if env var is unset."""
       username = os.environ.get("AIRFLOW__API_USERNAME", "api_user")
       password = os.environ.get("AIRFLOW__API_PWD")
       session = Session()  # sqlalchemy.orm.session under the hood
       delete_users(session, username)
       if password:  # empty env var treated as missing env var
           create_user(session, username, password)

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message