Skip to content

Commit c851476

Browse files
authored
V5: Breaking: Change default to disable private network access (#368)
1 parent 561ed26 commit c851476

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

docs/configuration.rst

+14-14
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,37 @@ CORS_INTERCEPT_EXCEPTIONS (:py:class:`bool`)
5454
Whether to deal with Flask exception handlers or leave them alone (with respect to CORS headers).
5555

5656
CORS_MAX_AGE (:py:class:`~datetime.timedelta`, :py:class:`int` or :py:class:`str`)
57-
The maximum time for which this CORS request may be cached.
57+
The maximum time for which this CORS request may be cached.
5858
This value is set as the :http:header:`Access-Control-Max-Age` header.
5959

6060
CORS_METHODS (:py:class:`~typing.List` or :py:class:`str`)
6161
The method(s) which the allowed origins are allowed to access.
6262
These are included in the :http:header:`Access-Control-Allow-Methods` response headers to the preflight OPTIONS requests.
63-
63+
6464
.. _cors_origins_setting:
6565

6666
CORS_ORIGINS (:py:class:`~typing.List`, :py:class:`str` or :py:class:`re.Pattern`)
6767
The origin(s) to allow requests from.
6868
An origin configured here that matches the value of the :http:header:`Origin` header in a preflight OPTIONS request is returned as the value of the :http:header:`Access-Control-Allow-Origin` response header.
6969

7070
CORS_RESOURCES (:py:class:`~typing.Dict`, :py:class:`~typing.List` or :py:class:`str`)
71-
The series of regular expression and (optionally) associated CORS options to be applied to the given resource path.
72-
71+
The series of regular expression and (optionally) associated CORS options to be applied to the given resource path.
72+
7373
If the value is a dictionary, it's keys must be regular expressions matching resources, and the values must be another dictionary of configuration options, as described in this section.
74-
75-
If the argument is a list, it is expected to be a list of regular expressions matching resources for which the app-wide configured options are applied.
76-
77-
If the argument is a string, it is expected to be a regular expression matching resources for which the app-wide configured options are applied.
74+
75+
If the argument is a list, it is expected to be a list of regular expressions matching resources for which the app-wide configured options are applied.
76+
77+
If the argument is a string, it is expected to be a regular expression matching resources for which the app-wide configured options are applied.
7878

7979
CORS_SEND_WILDCARD (:py:class:`bool`)
8080
If :ref:`CORS_ORIGINS <cors_origins_setting>` is ``"*"`` and this is true, then the :http:header:`Access-Control-Allow-Origin` response header's value with be ``"*"`` as well, instead of the value of the :http:header:`Origin` request header.
8181

8282
CORS_SUPPORTS_CREDENTIALS (:py:class:`bool`)
83-
Allows users to make authenticated requests.
84-
If true, injects the :http:header:`Access-Control-Allow-Credentials` header in responses.
85-
This allows cookies and credentials to be submitted across domains.
86-
87-
:note: This option cannot be used in conjunction with a "*" origin
83+
Allows users to make authenticated requests.
84+
If true, injects the :http:header:`Access-Control-Allow-Credentials` header in responses.
85+
This allows cookies and credentials to be submitted across domains.
86+
87+
:note: This option cannot be used in conjunction with a "*" origin
8888

8989
CORS_VARY_HEADER: (:py:class:`bool`)
9090
Enables or disables the injection of the :http:header:`Vary` response header is set to ``Origin``.
@@ -96,7 +96,7 @@ Default values
9696
~~~~~~~~~~~~~~
9797

9898
* CORS_ALLOW_HEADERS: "*"
99-
* CORS_ALLOW_PRIVATE_NETWORK: True
99+
* CORS_ALLOW_PRIVATE_NETWORK: False
100100
* CORS_ALWAYS_SEND: True
101101
* CORS_AUTOMATIC_OPTIONS: True
102102
* CORS_EXPOSE_HEADERS: None

flask_cors/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
resources=r'/*',
5858
intercept_exceptions=True,
5959
always_send=True,
60-
allow_private_network=True)
60+
allow_private_network=False)
6161

6262

6363
def parse_resources(resources):

flask_cors/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.0.2'
1+
__version__ = '5.0.0'

tests/decorator/test_private_network_headers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_default(self):
3737
""" The default behavior should be to allow private network access.
3838
"""
3939
resp = self.get('/test_default', origin='www.example.com', headers={ACL_REQUEST_HEADER_PRIVATE_NETWORK:'true'})
40-
self.assertTrue(ACL_RESPONSE_PRIVATE_NETWORK in resp.headers)
40+
self.assertFalse(resp.headers.get('ACL_RESPONSE_PRIVATE_NETWORK'))
4141

4242
resp = self.get('/test_default')
4343
self.assertFalse(ACL_RESPONSE_PRIVATE_NETWORK in resp.headers)

0 commit comments

Comments
 (0)