Skip to content

Commit cf20b34

Browse files
refactor: Removes the deprecated ENABLE_EXPLORE_JSON_CSRF_PROTECTION feature flag (#26344)
1 parent b06ab7d commit cf20b34

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

RESOURCES/FEATURE_FLAGS.md

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ These features flags currently default to True and **will be removed in a future
8686
- DASHBOARD_CROSS_FILTERS
8787
- DASHBOARD_FILTERS_EXPERIMENTAL
8888
- DASHBOARD_NATIVE_FILTERS
89-
- ENABLE_EXPLORE_JSON_CSRF_PROTECTION
9089
- ENABLE_JAVASCRIPT_CONTROLS
9190
- GENERIC_CHART_AXES
9291
- KV_STORE

UPDATING.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ assists people when migrating to a new version.
3030

3131
### Breaking Changes
3232

33+
- [26344](https://github.com/apache/superset/issues/26344): Removes the deprecated `ENABLE_EXPLORE_JSON_CSRF_PROTECTION` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed.
3334
- [26345](https://github.com/apache/superset/issues/26345): Removes the deprecated `ENABLE_TEMPLATE_REMOVE_FILTERS` feature flag. The previous value of the feature flag was `True` and now the feature is permanently enabled.
3435
- [26346](https://github.com/apache/superset/issues/26346): Removes the deprecated `REMOVE_SLICE_LEVEL_LABEL_COLORS` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed.
3536
- [26348](https://github.com/apache/superset/issues/26348): Removes the deprecated `CLIENT_CACHE` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed.

docs/docs/installation/configuring-superset.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ You can enable or disable features with flag from `superset_config.py`:
358358

359359
```python
360360
FEATURE_FLAGS = {
361-
'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False,
362361
'PRESTO_EXPAND_DATA': False,
363362
}
364363
```

superset/config.py

-8
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,6 @@ class D3Format(TypedDict, total=False):
409409
# editor no longer shows. Currently this is set to false so that the editor
410410
# option does show, but we will be depreciating it.
411411
"DISABLE_LEGACY_DATASOURCE_EDITOR": True,
412-
# For some security concerns, you may need to enforce CSRF protection on
413-
# all query request to explore_json endpoint. In Superset, we use
414-
# `flask-csrf <https://sjl.bitbucket.io/flask-csrf/>`_ add csrf protection
415-
# for all POST requests, but this protection doesn't apply to GET method.
416-
# When ENABLE_EXPLORE_JSON_CSRF_PROTECTION is set to true, your users cannot
417-
# make GET request to explore_json. explore_json accepts both GET and POST request.
418-
# See `PR 7935 <https://github.com/apache/superset/pull/7935>`_ for more details.
419-
"ENABLE_EXPLORE_JSON_CSRF_PROTECTION": False, # deprecated
420412
"ENABLE_TEMPLATE_PROCESSING": False,
421413
# Allow for javascript controls components
422414
# this enables programmers to customize certain charts (like the

superset/views/core.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
# pylint: disable=invalid-name
18+
# pylint: disable=too-many-lines
1819
from __future__ import annotations
1920

2021
import contextlib
@@ -238,19 +239,24 @@ def explore_json_data(self, cache_key: str) -> FlaskResponse:
238239
except SupersetException as ex:
239240
return json_error_response(utils.error_msg_from_exception(ex), 400)
240241

241-
EXPLORE_JSON_METHODS = ["POST"]
242-
if not is_feature_enabled("ENABLE_EXPLORE_JSON_CSRF_PROTECTION"):
243-
EXPLORE_JSON_METHODS.append("GET")
244-
245242
@api
246243
@has_access_api
247244
@handle_api_exception
248245
@event_logger.log_this
249246
@expose(
250247
"/explore_json/<datasource_type>/<int:datasource_id>/",
251-
methods=EXPLORE_JSON_METHODS,
248+
methods=(
249+
"GET",
250+
"POST",
251+
),
252+
)
253+
@expose(
254+
"/explore_json/",
255+
methods=(
256+
"GET",
257+
"POST",
258+
),
252259
)
253-
@expose("/explore_json/", methods=EXPLORE_JSON_METHODS)
254260
@etag_cache()
255261
@check_resource_permissions(check_datasource_perms)
256262
@deprecated(eol_version="4.0.0")

tests/integration_tests/core_tests.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,15 @@ def test_comments_in_sqlatable_query(self):
559559
self.assertEqual(clean_query, rendered_query)
560560

561561
def test_slice_payload_no_datasource(self):
562+
form_data = {
563+
"viz_type": "dist_bar",
564+
}
562565
self.login(username="admin")
563-
data = self.get_json_resp("/superset/explore_json/", raise_on_error=False)
566+
rv = self.client.post(
567+
"/superset/explore_json/",
568+
data={"form_data": json.dumps(form_data)},
569+
)
570+
data = json.loads(rv.data.decode("utf-8"))
564571

565572
self.assertEqual(
566573
data["errors"][0]["message"],

0 commit comments

Comments
 (0)