Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```python
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
session.add(admin)
session.commit()
```

## Airflow 1.10.1

### StatsD Metrics
Expand Down
3 changes: 1 addition & 2 deletions airflow/contrib/auth/backends/password_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


@login_manager.user_loader
Expand Down
42 changes: 42 additions & 0 deletions airflow/migrations/versions/41f5f12752f8_add_superuser_field.py
Original file line number Diff line number Diff line change
@@ -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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# 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')
2 changes: 1 addition & 1 deletion airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down