Skip to content

Commit bf62128

Browse files
committed
add authorizer_result property to inv ctx class
1 parent 4b811fe commit bf62128

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

localstack/services/apigateway/context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ def authorizer_type(self) -> str:
136136
if isinstance(self.auth_context, dict):
137137
return self.auth_context.get("authorizer_type") if self.auth_context else None
138138

139+
@property
140+
def authorizer_result(self) -> Dict[str, Any]:
141+
if isinstance(self.auth_context, dict):
142+
return self.auth_context.get("authorizer") if self.auth_context else {}
143+
139144
def is_websocket_request(self) -> bool:
140145
upgrade_header = str(self.headers.get("upgrade") or "")
141146
return upgrade_header.lower() == "websocket"

localstack/services/apigateway/helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,9 @@ def get_event_request_context(invocation_context: ApiInvocationContext):
822822
}
823823

824824
# set "authorizer" and "identity" event attributes from request context
825-
auth_context = invocation_context.auth_context
826-
if auth_context:
827-
request_context["authorizer"] = auth_context
825+
authorizer_result = invocation_context.authorizer_result
826+
if authorizer_result:
827+
request_context["authorizer"] = authorizer_result
828828
request_context["identity"].update(invocation_context.auth_identity or {})
829829

830830
if not is_test_invoke_method(method, path):

localstack/services/apigateway/integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def invoke(self, invocation_context: ApiInvocationContext):
268268
func_arn = uri.split(":lambda:path")[1].split("functions/")[1].split("/invocations")[0]
269269

270270
if invocation_context.authorizer_type:
271-
invocation_context.context["authorizer"] = invocation_context.auth_context
271+
invocation_context.context["authorizer"] = invocation_context.authorizer_result
272272

273273
payload = self.request_templates.render(invocation_context)
274274

@@ -343,7 +343,7 @@ def invoke(self, invocation_context: ApiInvocationContext):
343343
invocation_context.context = helpers.get_event_request_context(invocation_context)
344344
invocation_context.stage_variables = helpers.get_stage_variables(invocation_context)
345345
if invocation_context.authorizer_type:
346-
invocation_context.context["authorizer"] = invocation_context.auth_context
346+
invocation_context.context["authorizer"] = invocation_context.authorizer_result
347347

348348
func_arn = self._lambda_integration_uri(invocation_context)
349349
request_templates = RequestTemplates()

0 commit comments

Comments
 (0)