mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix(15482): Propagate SupersetSecurityException error (#15874)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
parent
4ba17092fa
commit
65728ea049
@ -2685,23 +2685,11 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
try:
|
try:
|
||||||
query.raise_for_access()
|
query.raise_for_access()
|
||||||
except SupersetSecurityException as ex:
|
except SupersetSecurityException as ex:
|
||||||
message = __(
|
query.set_extra_json_key("errors", [dataclasses.asdict(ex.error)])
|
||||||
"You are not authorized to see this query. If you think this "
|
|
||||||
"is an error, please reach out to your administrator."
|
|
||||||
)
|
|
||||||
error = SupersetError(
|
|
||||||
message=message,
|
|
||||||
error_type=SupersetErrorType.QUERY_SECURITY_ACCESS_ERROR,
|
|
||||||
level=ErrorLevel.ERROR,
|
|
||||||
)
|
|
||||||
error_payload = dataclasses.asdict(error)
|
|
||||||
|
|
||||||
query.set_extra_json_key("errors", [error_payload])
|
|
||||||
query.status = QueryStatus.FAILED
|
query.status = QueryStatus.FAILED
|
||||||
query.error_message = message
|
query.error_message = ex.error.message
|
||||||
session.commit()
|
session.commit()
|
||||||
|
raise SupersetErrorException(ex.error, status=403) from ex
|
||||||
raise SupersetErrorException(error, status=403) from ex
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
template_processor = get_template_processor(
|
template_processor = get_template_processor(
|
||||||
|
Loading…
Reference in New Issue
Block a user