Skip to content

Commit

Permalink
[AIRFLOW-6352] security - ui - add login timeout (#6912)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0721d62)
  • Loading branch information
tooptoop4 authored and potiuk committed Dec 30, 2019
1 parent b8a3e26 commit d12d400
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,13 @@ default_wrap = False
# on webserver startup
update_fab_perms = True

# Minutes of non-activity before logged out from UI
# 0 means never get forcibly logged out
force_log_out_after = 0

[email]
email_backend = airflow.utils.email.send_email_smtp


[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an
Expand Down
9 changes: 9 additions & 0 deletions airflow/www/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ def jinja_globals():
'navbar_color': conf.get('webserver', 'NAVBAR_COLOR'),
}

@app.before_request
def before_request():
_force_log_out_after = conf.getint('webserver', 'FORCE_LOG_OUT_AFTER', fallback=0)
if _force_log_out_after > 0:
flask.session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(minutes=_force_log_out_after)
flask.session.modified = True
flask.g.user = flask_login.current_user

@app.teardown_appcontext
def shutdown_session(exception=None):
settings.Session.remove()
Expand Down

0 comments on commit d12d400

Please sign in to comment.