Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Revert "chore(security): Renaming schemas_accessible_by_user (apache#…
Browse files Browse the repository at this point in the history
…10030)"

This reverts commit 54c6ddb.
  • Loading branch information
michelle_thomas committed Jun 17, 2020
1 parent f7bb08c commit eb4b02a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 0 additions & 2 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ assists people when migrating to a new version.

## Next

* [10030](https://github.com/apache/incubator-superset/pull/10030): Renames the public security manager `schemas_accessible_by_user` method to `get_schemas_accessible_by_user`.

* [9786](https://github.com/apache/incubator-superset/pull/9786): with the upgrade of `werkzeug` from version `0.16.0` to `1.0.1`, the `werkzeug.contrib.cache` module has been moved to a standalone package [cachelib](https://pypi.org/project/cachelib/). For example, to import the `RedisCache` class, please use the following import: `from cachelib.redis import RedisCache`.

* [9572](https://github.com/apache/incubator-superset/pull/9572): a change which by defau;t means that the Jinja `current_user_id`, `current_username`, and `url_param` context calls no longer need to be wrapped via `cache_key_wrapper` in order to be included in the cache key. The `cache_key_wrapper` function should only be required for Jinja add-ons.
Expand Down
4 changes: 2 additions & 2 deletions superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ def user_view_menu_names(self, permission_name: str) -> Set[str]:
return set([s.name for s in view_menu_names])
return set()

def get_schemas_accessible_by_user(
def schemas_accessible_by_user(
self, database: "Database", schemas: List[str], hierarchical: bool = True
) -> List[str]:
"""
Return the list of SQL schemas accessible by the user.
Return the sorted list of SQL schemas accessible by the user.
:param database: The SQL database
:param schemas: The list of eligible SQL schemas
Expand Down
4 changes: 2 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ def schemas(self, db_id: int, force_refresh: str = "false") -> FlaskResponse:
cache_timeout=database.schema_cache_timeout,
force=force_refresh.lower() == "true",
)
schemas = security_manager.get_schemas_accessible_by_user(database, schemas)
schemas = security_manager.schemas_accessible_by_user(database, schemas)
else:
schemas = []

Expand Down Expand Up @@ -2906,7 +2906,7 @@ def schemas_access_for_csv_upload(self) -> FlaskResponse:
# should not be empty either,
# otherwise the database should have been filtered out
# in CsvToDatabaseForm
schemas_allowed_processed = security_manager.get_schemas_accessible_by_user(
schemas_allowed_processed = security_manager.schemas_accessible_by_user(
database, schemas_allowed, False
)
return self.json_response(schemas_allowed_processed)
Expand Down
2 changes: 1 addition & 1 deletion superset/views/database/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def at_least_one_schema_is_allowed(database: Database) -> bool:
):
return True
schemas = database.get_schema_access_for_csv_upload()
if schemas and security_manager.get_schemas_accessible_by_user(
if schemas and security_manager.schemas_accessible_by_user(
database, schemas, False
):
return True
Expand Down
4 changes: 1 addition & 3 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,7 @@ def test_slice_payload_no_datasource(self):
"The datasource associated with this chart no longer exists",
)

@mock.patch(
"superset.security.SupersetSecurityManager.get_schemas_accessible_by_user"
)
@mock.patch("superset.security.SupersetSecurityManager.schemas_accessible_by_user")
@mock.patch("superset.security.SupersetSecurityManager.database_access")
@mock.patch("superset.security.SupersetSecurityManager.all_datasource_access")
def test_schemas_access_for_csv_upload_endpoint(
Expand Down
8 changes: 4 additions & 4 deletions tests/security_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def test_schemas_accessible_by_user_admin(self, mock_g):
mock_g.user = security_manager.find_user("admin")
with self.client.application.test_request_context():
database = get_example_database()
schemas = security_manager.get_schemas_accessible_by_user(
schemas = security_manager.schemas_accessible_by_user(
database, ["1", "2", "3"]
)
self.assertEquals(schemas, ["1", "2", "3"]) # no changes
Expand All @@ -424,7 +424,7 @@ def test_schemas_accessible_by_user_schema_access(self, mock_g):
mock_g.user = security_manager.find_user("gamma")
with self.client.application.test_request_context():
database = get_example_database()
schemas = security_manager.get_schemas_accessible_by_user(
schemas = security_manager.schemas_accessible_by_user(
database, ["1", "2", "3"]
)
# temp_schema is not passed in the params
Expand All @@ -437,7 +437,7 @@ def test_schemas_accessible_by_user_datasource_access(self, mock_g):
mock_g.user = security_manager.find_user("gamma")
with self.client.application.test_request_context():
database = get_example_database()
schemas = security_manager.get_schemas_accessible_by_user(
schemas = security_manager.schemas_accessible_by_user(
database, ["temp_schema", "2", "3"]
)
self.assertEquals(schemas, ["temp_schema"])
Expand All @@ -449,7 +449,7 @@ def test_schemas_accessible_by_user_datasource_and_schema_access(self, mock_g):
mock_g.user = security_manager.find_user("gamma")
with self.client.application.test_request_context():
database = get_example_database()
schemas = security_manager.get_schemas_accessible_by_user(
schemas = security_manager.schemas_accessible_by_user(
database, ["temp_schema", "2", "3"]
)
self.assertEquals(schemas, ["temp_schema", "2"])
Expand Down

0 comments on commit eb4b02a

Please sign in to comment.