You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/data_classes.md
+38-30
Original file line number
Diff line number
Diff line change
@@ -87,19 +87,17 @@ Event Source | Data_class
87
87
88
88
> New in 1.20.0
89
89
90
-
It is used for API Gateway Rest API lambda authorizer payload. See docs on
91
-
[Use API Gateway Lambda authorizers](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html){target="_blank"}
92
-
for more details. Use `APIGatewayAuthorizerRequestEvent` for type "REQUEST" and `APIGatewayAuthorizerTokenEvent` for
93
-
type "TOKEN".
90
+
It is used for [API Gateway Rest API Lambda Authorizer payload](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html){target="_blank"}.
94
91
95
-
Below is 2 examples of a Rest API lambda authorizer. One looking up user details by `Authorization` header and using
96
-
`APIGatewayAuthorizerResponse` to return the declined response when user is not found or authorized and include
97
-
the user details in the request context and full access for admin users. And another using
98
-
`APIGatewayAuthorizerTokenEvent` to get the `authorization_token`.
92
+
Use **`APIGatewayAuthorizerRequestEvent`** for type `REQUEST` and **`APIGatewayAuthorizerTokenEvent`** for type `TOKEN`.
99
93
100
94
=== "app_type_request.py"
101
95
102
-
```python
96
+
This example uses the `APIGatewayAuthorizerResponse` to decline a given request if the user is not found.
97
+
98
+
When the user is found, it includes the user details in the request context that will be available to the back-end, and returns a full access policy for admin users.
99
+
100
+
```python hl_lines="2-5 26-31 36-37 40 44 46"
103
101
from aws_lambda_powertools.utilities.data_classes import event_source
104
102
from aws_lambda_powertools.utilities.data_classes.api_gateway_authorizer_event import (
105
103
APIGatewayAuthorizerRequestEvent,
@@ -125,27 +123,33 @@ the user details in the request context and full access for admin users. And ano
125
123
# parse the `methodArn` as an `APIGatewayRouteArn`
126
124
arn = event.parsed_arn
127
125
# Create the response builder from parts of the `methodArn`
It is used for API Gateway HTTP API lambda authorizer payload version 2. See blog post
172
-
[Introducing IAM and Lambda authorizers for Amazon API Gateway HTTP APIs](https://aws.amazon.com/blogs/compute/introducing-iam-and-lambda-authorizers-for-amazon-api-gateway-http-apis/){target="_blank"}
173
-
or [Working with AWS Lambda authorizers for HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html){target="_blank"}
174
-
for more details
175
-
176
-
Below is a simple example of an HTTP API lambda authorizer looking up user details by `x-token` header and using
177
-
`APIGatewayAuthorizerResponseV2` to return the declined response when user is not found or authorized and include
178
-
the user details in the request context.
183
+
It is used for [API Gateway HTTP API Lambda Authorizer payload version 2](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html){target="_blank"}.
184
+
See also [this blog post](https://aws.amazon.com/blogs/compute/introducing-iam-and-lambda-authorizers-for-amazon-api-gateway-http-apis/){target="_blank"} for more details.
179
185
180
186
=== "app.py"
181
187
182
-
```python
188
+
This example looks up user details via `x-token` header. It uses `APIGatewayAuthorizerResponseV2` to return a deny policy when user is not found or authorized.
189
+
190
+
```python hl_lines="2-5 21 24"
183
191
from aws_lambda_powertools.utilities.data_classes import event_source
184
192
from aws_lambda_powertools.utilities.data_classes.api_gateway_authorizer_event import (
0 commit comments