ashb closed pull request #4276: [AIRFLOW-1552] Airflow Filter_by_owner not 
working with password_auth

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ b/
index 88dc78c810..814e2e107d 100644
--- a/
+++ b/
@@ -76,6 +76,24 @@ To delete a user:
 airflow users --delete --username jondoe
+### User model changes
+This patch changes the `User.superuser` field from a hardcoded boolean to a 
`Boolean()` database column. `User.superuser` will default to `False`, which 
means that this privilege will have to be granted manually to any users that 
may require it.
+For example, open a Python shell and
+from airflow import models, settings
+session = settings.Session()
+users = session.query(models.User).all()  # [admin, regular_user]
+users[1].superuser  # False
+admin = users[0]
+admin.superuser = True
 ## Airflow 1.10.1
 ### StatsD Metrics
diff --git a/airflow/contrib/auth/backends/ 
index 55f5daf8fd..dcdb1d1225 100644
--- a/airflow/contrib/auth/backends/
+++ b/airflow/contrib/auth/backends/
@@ -95,8 +95,7 @@ def data_profiling(self):
         return True
     def is_superuser(self):
-        """Access all the things"""
-        return True
+        return hasattr(self, 'user') and self.user.is_superuser()
diff --git a/airflow/migrations/versions/ 
new file mode 100644
index 0000000000..6e02582b7e
--- /dev/null
+++ b/airflow/migrations/versions/
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""add superuser field
+Revision ID: 41f5f12752f8
+Revises: 03bc53e68815
+Create Date: 2018-12-04 15:50:04.456875
+from alembic import op
+import sqlalchemy as sa
+# revision identifiers, used by Alembic.
+revision = '41f5f12752f8'
+down_revision = '03bc53e68815'
+branch_labels = None
+depends_on = None
+def upgrade():
+    op.add_column('users', sa.Column('superuser', sa.Boolean(), default=False))
+def downgrade():
+    op.drop_column('users', 'superuser')
diff --git a/airflow/ b/airflow/
index 1bca27cbc8..a6d0ebbd73 100755
--- a/airflow/
+++ b/airflow/
@@ -601,7 +601,7 @@ class User(Base):
     id = Column(Integer, primary_key=True)
     username = Column(String(ID_LEN), unique=True)
     email = Column(String(500))
-    superuser = False
+    superuser = Column(Boolean(), default=False)
     def __repr__(self):
         return self.username


This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to