Skip to content

Commit

Permalink
[FAB] configuring updating of permissions (#4172)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and mistercrunch committed Jan 8, 2018
1 parent 9364fb5 commit d570120
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
23 changes: 22 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,27 @@ work on Windows so the `superset runserver` command is not expected to work
in that context. Also note that the development web
server (`superset runserver -d`) is not intended for production use.

Flask-AppBuilder Permissions
----------------------------

By default every time the Flask-AppBuilder (FAB) app is initialized the
permissions and views are added automatically to the backend and associated with
the ‘Admin’ role. The issue however is when you are running multiple concurrent
workers this creates a lot of contention and race conditions when defining
permissions and views.

To alleviate this issue, the automatic updating of permissions can be disabled
by setting the :envvar:`SUPERSET_UPDATE_PERMS` environment variable to `0`.
The value `1` enables it, `0` disables it. Note if undefined the functionality
is enabled to maintain backwards compatibility.

In a production environment initialization could take on the following form:

export SUPERSET_UPDATE_PERMS=1
superset init

export SUPERSET_UPDATE_PERMS=0
gunicorn -w 10 ... superset:app

Configuration behind a load balancer
------------------------------------
Expand All @@ -181,7 +202,7 @@ If the load balancer is inserting X-Forwarded-For/X-Forwarded-Proto headers, you
should set `ENABLE_PROXY_FIX = True` in the superset config file to extract and use
the headers.

In case that the reverse proxy is used for providing ssl encryption,
In case that the reverse proxy is used for providing ssl encryption,
an explicit definition of the `X-Forwarded-Proto` may be required.
For the Apache webserver this can be set as follows: ::

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_git_sha():
'colorama==0.3.9',
'cryptography==1.9',
'flask==0.12.2',
'flask-appbuilder==1.9.4',
'flask-appbuilder==1.9.5',
'flask-cache==0.13.1',
'flask-migrate==2.0.3',
'flask-script==2.0.5',
Expand Down
4 changes: 3 additions & 1 deletion superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def index(self):
db.session,
base_template='superset/base.html',
indexview=MyIndexView,
security_manager_class=app.config.get('CUSTOM_SECURITY_MANAGER'))
security_manager_class=app.config.get('CUSTOM_SECURITY_MANAGER'),
update_perms=utils.get_update_perms_flag(),
)

sm = appbuilder.sm

Expand Down
5 changes: 5 additions & 0 deletions superset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,8 @@ def get_filter_key(f):
form_data['filters'] += [filtr]
# Remove extra filters from the form data since no longer needed
del form_data['extra_filters']


def get_update_perms_flag():
val = os.environ.get('SUPERSET_UPDATE_PERMS')
return val.lower() not in ('0', 'false', 'no') if val else True

0 comments on commit d570120

Please sign in to comment.