Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(security): Renaming schemas_accessible_by_user #10030

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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 schemas_accessible_by_user(
def get_schemas_accessible_by_user(
self, database: "Database", schemas: List[str], hierarchical: bool = True
) -> List[str]:
"""
Return the sorted list of SQL schemas accessible by the user.
Return the 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 @@ -1130,7 +1130,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.schemas_accessible_by_user(database, schemas)
schemas = security_manager.get_schemas_accessible_by_user(database, schemas)
else:
schemas = []

Expand Down Expand Up @@ -2907,7 +2907,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.schemas_accessible_by_user(
schemas_allowed_processed = security_manager.get_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.schemas_accessible_by_user(
if schemas and security_manager.get_schemas_accessible_by_user(
database, schemas, False
):
return True
Expand Down
4 changes: 3 additions & 1 deletion tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,9 @@ def test_slice_payload_no_datasource(self):
"The datasource associated with this chart no longer exists",
)

@mock.patch("superset.security.SupersetSecurityManager.schemas_accessible_by_user")
@mock.patch(
"superset.security.SupersetSecurityManager.get_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.schemas_accessible_by_user(
schemas = security_manager.get_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.schemas_accessible_by_user(
schemas = security_manager.get_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.schemas_accessible_by_user(
schemas = security_manager.get_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.schemas_accessible_by_user(
schemas = security_manager.get_schemas_accessible_by_user(
database, ["temp_schema", "2", "3"]
)
self.assertEquals(schemas, ["temp_schema", "2"])
Expand Down