Skip to content

Commit bc68c21

Browse files
sanathkrjfuss
authored andcommitted
Revert "feat(CORS): Set the CORS "Access-Control-Allow-Credentials" for local running (aws#1648)" (aws#1664)
This reverts commit cd3ec84.
1 parent 09d2e01 commit bc68c21

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

samcli/commands/local/lib/provider.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,13 @@ def binary_media_types(self):
220220
return list(self.binary_media_types_set)
221221

222222

223-
_CorsTuple = namedtuple("Cors", ["allow_origin", "allow_methods", "allow_headers", "allow_credentials", "max_age"])
223+
_CorsTuple = namedtuple("Cors", ["allow_origin", "allow_methods", "allow_headers", "max_age"])
224224

225225

226226
_CorsTuple.__new__.__defaults__ = (
227227
None, # Allow Origin defaults to None
228228
None, # Allow Methods is optional and defaults to empty
229229
None, # Allow Headers is optional and defaults to empty
230-
None, # Allow Credentials is optional and defaults to empty
231230
None, # MaxAge is optional and defaults to empty
232231
)
233232

@@ -251,7 +250,6 @@ def cors_to_headers(cors):
251250
"Access-Control-Allow-Origin": cors.allow_origin,
252251
"Access-Control-Allow-Methods": cors.allow_methods,
253252
"Access-Control-Allow-Headers": cors.allow_headers,
254-
"Access-Control-Allow-Credentials": cors.allow_credentials,
255253
"Access-Control-Max-Age": cors.max_age,
256254
}
257255
# Filters out items in the headers dictionary that isn't empty.

samcli/commands/local/lib/sam_api_provider.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,10 @@ def extract_cors(self, cors_prop):
111111

112112
allow_origin = self._get_cors_prop(cors_prop, "AllowOrigin")
113113
allow_headers = self._get_cors_prop(cors_prop, "AllowHeaders")
114-
allow_credentials = self._get_cors_prop(cors_prop, "AllowCredentials", is_string=False)
115114
max_age = self._get_cors_prop(cors_prop, "MaxAge")
116115

117116
cors = Cors(
118-
allow_origin=allow_origin,
119-
allow_methods=allow_methods,
120-
allow_headers=allow_headers,
121-
allow_credentials=allow_credentials,
122-
max_age=max_age,
117+
allow_origin=allow_origin, allow_methods=allow_methods, allow_headers=allow_headers, max_age=max_age
123118
)
124119
elif cors_prop and isinstance(cors_prop, string_types):
125120
allow_origin = cors_prop
@@ -133,13 +128,12 @@ def extract_cors(self, cors_prop):
133128
allow_origin=allow_origin,
134129
allow_methods=",".join(sorted(Route.ANY_HTTP_METHODS)),
135130
allow_headers=None,
136-
allow_credentials=None,
137131
max_age=None,
138132
)
139133
return cors
140134

141135
@staticmethod
142-
def _get_cors_prop(cors_dict, prop_name, is_string=True):
136+
def _get_cors_prop(cors_dict, prop_name):
143137
"""
144138
Extract cors properties from dictionary and remove extra quotes.
145139
@@ -153,7 +147,7 @@ def _get_cors_prop(cors_dict, prop_name, is_string=True):
153147
A string with the extra quotes removed
154148
"""
155149
prop = cors_dict.get(prop_name)
156-
if prop and is_string:
150+
if prop:
157151
if (not isinstance(prop, string_types)) or (not (prop.startswith("'") and prop.endswith("'"))):
158152
raise InvalidSamDocumentException(
159153
"{} must be a quoted string " '(i.e. "\'value\'" is correct, but "value" is not).'.format(prop_name)

tests/unit/commands/local/lib/test_sam_api_provider.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ def test_provider_parse_cors_dict(self):
875875
"AllowMethods": "'POST, GET'",
876876
"AllowOrigin": "'*'",
877877
"AllowHeaders": "'Upgrade-Insecure-Requests'",
878-
"AllowCredentials": True,
879878
"MaxAge": "'600'",
880879
},
881880
"DefinitionBody": {
@@ -918,7 +917,6 @@ def test_provider_parse_cors_dict(self):
918917
allow_origin="*",
919918
allow_methods=",".join(sorted(["POST", "GET", "OPTIONS"])),
920919
allow_headers="Upgrade-Insecure-Requests",
921-
allow_credentials=True,
922920
max_age="600",
923921
)
924922
route1 = Route(path="/path2", methods=["POST", "OPTIONS"], function_name="NoApiEventFunction")

0 commit comments

Comments
 (0)