security.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. .. Licensed to the Apache Software Foundation (ASF) under one
  2. or more contributor license agreements. See the NOTICE file
  3. distributed with this work for additional information
  4. regarding copyright ownership. The ASF licenses this file
  5. to you under the Apache License, Version 2.0 (the
  6. "License"); you may not use this file except in compliance
  7. with the License. You may obtain a copy of the License at
  8. .. http://www.apache.org/licenses/LICENSE-2.0
  9. .. Unless required by applicable law or agreed to in writing,
  10. software distributed under the License is distributed on an
  11. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND, either express or implied. See the License for the
  13. specific language governing permissions and limitations
  14. under the License.
  15. Security
  16. ========
  17. Security in Superset is handled by Flask AppBuilder (FAB). FAB is a
  18. "Simple and rapid application development framework, built on top of Flask.".
  19. FAB provides authentication, user management, permissions and roles.
  20. Please read its `Security documentation
  21. <https://flask-appbuilder.readthedocs.io/en/latest/security.html>`_.
  22. Provided Roles
  23. --------------
  24. Superset ships with a set of roles that are handled by Superset itself.
  25. You can assume that these roles will stay up-to-date as Superset evolves.
  26. Even though it's possible for ``Admin`` users to do so, it is not recommended
  27. that you alter these roles in any way by removing
  28. or adding permissions to them as these roles will be re-synchronized to
  29. their original values as you run your next ``superset init`` command.
  30. Since it's not recommended to alter the roles described here, it's right
  31. to assume that your security strategy should be to compose user access based
  32. on these base roles and roles that you create. For instance you could
  33. create a role ``Financial Analyst`` that would be made of a set of permissions
  34. to a set of data sources (tables) and/or databases. Users would then be
  35. granted ``Gamma``, ``Financial Analyst``, and perhaps ``sql_lab``.
  36. Admin
  37. """""
  38. Admins have all possible rights, including granting or revoking rights from
  39. other users and altering other people's slices and dashboards.
  40. Alpha
  41. """""
  42. Alpha users have access to all data sources, but they cannot grant or revoke access
  43. from other users. They are also limited to altering the objects that they
  44. own. Alpha users can add and alter data sources.
  45. Gamma
  46. """""
  47. Gamma users have limited access. They can only consume data coming from data sources
  48. they have been given access to through another complementary role.
  49. They only have access to view the slices and
  50. dashboards made from data sources that they have access to. Currently Gamma
  51. users are not able to alter or add data sources. We assume that they are
  52. mostly content consumers, though they can create slices and dashboards.
  53. Also note that when Gamma users look at the dashboards and slices list view,
  54. they will only see the objects that they have access to.
  55. sql_lab
  56. """""""
  57. The ``sql_lab`` role grants access to SQL Lab. Note that while ``Admin``
  58. users have access to all databases by default, both ``Alpha`` and ``Gamma``
  59. users need to be given access on a per database basis.
  60. Public
  61. """"""
  62. It's possible to allow logged out users to access some Superset features.
  63. By setting ``PUBLIC_ROLE_LIKE_GAMMA = True`` in your ``superset_config.py``,
  64. you grant public role the same set of permissions as for the GAMMA role.
  65. This is useful if one wants to enable anonymous users to view
  66. dashboards. Explicit grant on specific datasets is still required, meaning
  67. that you need to edit the ``Public`` role and add the Public data sources
  68. to the role manually.
  69. Managing Gamma per data source access
  70. -------------------------------------
  71. Here's how to provide users access to only specific datasets. First make
  72. sure the users with limited access have [only] the Gamma role assigned to
  73. them. Second, create a new role (``Menu -> Security -> List Roles``) and
  74. click the ``+`` sign.
  75. .. image:: _static/images/create_role.png
  76. :scale: 50 %
  77. This new window allows you to give this new role a name, attribute it to users
  78. and select the tables in the ``Permissions`` dropdown. To select the data
  79. sources you want to associate with this role, simply click on the dropdown
  80. and use the typeahead to search for your table names.
  81. You can then confirm with your Gamma users that they see the objects
  82. (dashboards and slices) associated with the tables related to their roles.
  83. Customizing
  84. -----------
  85. The permissions exposed by FAB are very granular and allow for a great level
  86. of customization. FAB creates many permissions automagically for each model
  87. that is created (can_add, can_delete, can_show, can_edit, ...) as well as for
  88. each view. On top of that, Superset can expose more granular permissions like
  89. ``all_datasource_access``.
  90. We do not recommend altering the 3 base roles as there
  91. are a set of assumptions that Superset is built upon. It is possible though for
  92. you to create your own roles, and union them to existing ones.
  93. Permissions
  94. """""""""""
  95. Roles are composed of a set of permissions, and Superset has many categories
  96. of permissions. Here are the different categories of permissions:
  97. - **Model & action**: models are entities like ``Dashboard``,
  98. ``Slice``, or ``User``. Each model has a fixed set of permissions, like
  99. ``can_edit``, ``can_show``, ``can_delete``, ``can_list``, ``can_add``, and
  100. so on. By adding ``can_delete on Dashboard`` to a role, and granting that
  101. role to a user, this user will be able to delete dashboards.
  102. - **Views**: views are individual web pages, like the ``explore`` view or the
  103. ``SQL Lab`` view. When granted to a user, he/she will see that view in its menu items, and be able to load that page.
  104. - **Data source**: For each data source, a permission is created. If the user
  105. does not have the ``all_datasource_access`` permission granted, the user
  106. will only be able to see Slices or explore the data sources that are granted
  107. to them
  108. - **Database**: Granting access to a database allows for the user to access
  109. all data sources within that database, and will enable the user to query
  110. that database in SQL Lab, provided that the SQL Lab specific permission
  111. have been granted to the user
  112. Restricting access to a subset of data sources
  113. """"""""""""""""""""""""""""""""""""""""""""""
  114. The best way to go is probably to give user ``Gamma`` plus one or many other
  115. roles that would add access to specific data sources. We recommend that you
  116. create individual roles for each access profile. Say people in your finance
  117. department might have access to a set of databases and data sources, and
  118. these permissions can be consolidated in a single role. Users with this
  119. profile then need to be attributed ``Gamma`` as a foundation to the models
  120. and views they can access, and that ``Finance`` role that is a collection
  121. of permissions to data objects.
  122. One user can have many roles, so a finance executive could be granted
  123. ``Gamma``, ``Finance``, and perhaps another ``Executive`` role that gather
  124. a set of data sources that power dashboards only made available to executives.
  125. When looking at its dashboard list, this user will only see the
  126. list of dashboards it has access to, based on the roles and
  127. permissions that were attributed.