Skip to content

Commit 35f996b

Browse files
jmcarpashb
authored andcommitted
[AIRFLOW-3103][AIRFLOW-3147] Update flask-appbuilder (apache#3937)
1 parent bc97e6e commit 35f996b

14 files changed

+50
-23
lines changed

UPDATING.md

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
This file documents any backwards-incompatible changes in Airflow and
44
assists users migrating to a new version.
55

6-
## Airflow Master
7-
8-
### min_file_parsing_loop_time config option temporarily disabled
9-
10-
The scheduler.min_file_parsing_loop_time config option has been temporarily removed due to
11-
some bugs.
12-
136
## Airflow 1.10
147

158
Installation and upgrading requires setting `SLUGIFY_USES_TEXT_UNIDECODE=yes` in your environment or
@@ -119,6 +112,22 @@ elasticsearch_log_id_template = {{dag_id}}-{{task_id}}-{{execution_date}}-{{try_
119112
elasticsearch_end_of_log_mark = end_of_log
120113
```
121114

115+
### Custom auth backends interface change
116+
117+
We have updated the version of flask-login we depend upon, and as a result any
118+
custom auth backends might need a small change: `is_active`,
119+
`is_authenticated`, and `is_anonymous` should now be properties. What this means is if
120+
previously you had this in your user class
121+
122+
def is_active(self):
123+
return self.active
124+
125+
then you need to change it like this
126+
127+
@property
128+
def is_active(self):
129+
return self.active
130+
122131
## Airflow 1.9
123132

124133
### SSH Hook updates, along with new SSH Operator & SFTP Operator

airflow/contrib/auth/backends/github_enterprise_auth.py

+3
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ class GHEUser(models.User):
4747
def __init__(self, user):
4848
self.user = user
4949

50+
@property
5051
def is_active(self):
5152
"""Required by flask_login"""
5253
return True
5354

55+
@property
5456
def is_authenticated(self):
5557
"""Required by flask_login"""
5658
return True
5759

60+
@property
5861
def is_anonymous(self):
5962
"""Required by flask_login"""
6063
return False

airflow/contrib/auth/backends/google_auth.py

+3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ class GoogleUser(models.User):
4646
def __init__(self, user):
4747
self.user = user
4848

49+
@property
4950
def is_active(self):
5051
"""Required by flask_login"""
5152
return True
5253

54+
@property
5355
def is_authenticated(self):
5456
"""Required by flask_login"""
5557
return True
5658

59+
@property
5760
def is_anonymous(self):
5861
"""Required by flask_login"""
5962
return False

airflow/contrib/auth/backends/kerberos_auth.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,17 @@ def authenticate(username, password):
7373

7474
return
7575

76+
@property
7677
def is_active(self):
7778
"""Required by flask_login"""
7879
return True
7980

81+
@property
8082
def is_authenticated(self):
8183
"""Required by flask_login"""
8284
return True
8385

86+
@property
8487
def is_anonymous(self):
8588
"""Required by flask_login"""
8689
return False
@@ -110,7 +113,7 @@ def load_user(userid, session=None):
110113

111114
@provide_session
112115
def login(self, request, session=None):
113-
if current_user.is_authenticated():
116+
if current_user.is_authenticated:
114117
flash("You are already logged in")
115118
return redirect(url_for('index'))
116119

airflow/contrib/auth/backends/ldap_auth.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,17 @@ def try_login(username, password):
236236
log.info("Password incorrect for user %s", username)
237237
raise AuthenticationError("Invalid username or password")
238238

239+
@property
239240
def is_active(self):
240241
"""Required by flask_login"""
241242
return True
242243

244+
@property
243245
def is_authenticated(self):
244246
"""Required by flask_login"""
245247
return True
246248

249+
@property
247250
def is_anonymous(self):
248251
"""Required by flask_login"""
249252
return False
@@ -274,7 +277,7 @@ def load_user(userid, session=None):
274277

275278
@provide_session
276279
def login(self, request, session=None):
277-
if current_user.is_authenticated():
280+
if current_user.is_authenticated:
278281
flash("You are already logged in")
279282
return redirect(url_for('admin.index'))
280283

airflow/contrib/auth/backends/password_auth.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ def password(self, plaintext):
7171
def authenticate(self, plaintext):
7272
return check_password_hash(self._password, plaintext)
7373

74+
@property
7475
def is_active(self):
7576
"""Required by flask_login"""
7677
return True
7778

79+
@property
7880
def is_authenticated(self):
7981
"""Required by flask_login"""
8082
return True
8183

84+
@property
8285
def is_anonymous(self):
8386
"""Required by flask_login"""
8487
return False
@@ -137,7 +140,7 @@ def authenticate(session, username, password):
137140

138141
@provide_session
139142
def login(self, request, session=None):
140-
if current_user.is_authenticated():
143+
if current_user.is_authenticated:
141144
flash("You are already logged in")
142145
return redirect(url_for('admin.index'))
143146

airflow/default_login.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ class DefaultUser(object):
4444
def __init__(self, user):
4545
self.user = user
4646

47+
@property
4748
def is_active(self):
4849
"""Required by flask_login"""
4950
return True
5051

52+
@property
5153
def is_authenticated(self):
5254
"""Required by flask_login"""
5355
return True
5456

57+
@property
5558
def is_anonymous(self):
5659
"""Required by flask_login"""
5760
return False

airflow/www/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class LoginMixin(object):
7171
def is_accessible(self):
7272
return (
7373
not AUTHENTICATE or (
74-
not current_user.is_anonymous() and
75-
current_user.is_authenticated()
74+
not current_user.is_anonymous and
75+
current_user.is_authenticated
7676
)
7777
)
7878

@@ -81,15 +81,15 @@ class SuperUserMixin(object):
8181
def is_accessible(self):
8282
return (
8383
not AUTHENTICATE or
84-
(not current_user.is_anonymous() and current_user.is_superuser())
84+
(not current_user.is_anonymous and current_user.is_superuser())
8585
)
8686

8787

8888
class DataProfilingMixin(object):
8989
def is_accessible(self):
9090
return (
9191
not AUTHENTICATE or
92-
(not current_user.is_anonymous() and current_user.data_profiling())
92+
(not current_user.is_anonymous and current_user.data_profiling())
9393
)
9494

9595

airflow/www/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def data_profiling_required(f):
266266
def decorated_function(*args, **kwargs):
267267
if (
268268
current_app.config['LOGIN_DISABLED'] or
269-
(not current_user.is_anonymous() and current_user.data_profiling())
269+
(not current_user.is_anonymous and current_user.data_profiling())
270270
):
271271
return f(*args, **kwargs)
272272
else:

airflow/www_rbac/decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def action_logging(f):
3232
@functools.wraps(f)
3333
def wrapper(*args, **kwargs):
3434
session = settings.Session()
35-
if g.user.is_anonymous():
35+
if g.user.is_anonymous:
3636
user = 'anonymous'
3737
else:
3838
user = g.user.username

airflow/www_rbac/security.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def init_roles(appbuilder):
171171

172172

173173
def is_view_only(user, appbuilder):
174-
if user.is_anonymous():
174+
if user.is_anonymous:
175175
anonymous_role = appbuilder.sm.auth_role_public
176176
return anonymous_role == 'Viewer'
177177

airflow/www_rbac/templates/appbuilder/navbar_right.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<!-- clock -->
4848
<li><a id="clock"></a></li>
4949

50-
{% if not current_user.is_anonymous() %}
50+
{% if not current_user.is_anonymous %}
5151
<li class="dropdown">
5252
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
5353
<span class="fa fa-user"></span> {{g.user.get_full_name()}}<b class="caret"></b>

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ def do_setup():
275275
'croniter>=0.3.17, <0.4',
276276
'dill>=0.2.2, <0.3',
277277
'flask>=0.12.4, <0.13',
278-
'flask-appbuilder>=1.11.1, <2.0.0',
278+
'flask-appbuilder>=1.12, <2.0.0',
279279
'flask-admin==1.4.1',
280280
'flask-caching>=1.3.3, <1.4.0',
281-
'flask-login==0.2.11',
281+
'flask-login>=0.3, <0.5',
282282
'flask-swagger==0.2.13',
283283
'flask-wtf>=0.14.2, <0.15',
284284
'funcsigs==1.0.0',

tests/www/test_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def test_params_all(self):
116116
self.assertEqual('page=3&search=bash_&showPaused=False',
117117
utils.get_params(showPaused=False, page=3, search='bash_'))
118118

119-
# flask_login is loaded by calling flask_login._get_user.
120-
@mock.patch("flask_login._get_user")
119+
# flask_login is loaded by calling flask_login.utils._get_user.
120+
@mock.patch("flask_login.utils._get_user")
121121
@mock.patch("airflow.settings.Session")
122122
def test_action_logging_with_login_user(self, mocked_session, mocked_get_user):
123123
fake_username = 'someone'
@@ -142,7 +142,7 @@ def some_func():
142142
self.assertEqual(fake_username, kwargs['owner'])
143143
mocked_session_instance.add.assert_called_once()
144144

145-
@mock.patch("flask_login._get_user")
145+
@mock.patch("flask_login.utils._get_user")
146146
@mock.patch("airflow.settings.Session")
147147
def test_action_logging_with_invalid_user(self, mocked_session, mocked_get_user):
148148
anonymous_username = 'anonymous'

0 commit comments

Comments
 (0)