- Newest
- Most votes
- Most comments
there are ways to achieve what you want in your Lambda function for a JWT-based authentication flow using Cognito:
-
Using Cognito Authorizer Claims (Recommended): This method leverages claims added to the JWT token by the Cognito authorizer. Here's how it works: Configure Claims in Cognito: In your Cognito user pool, navigate to "App integration settings" for your client app. Under "User pool mapping," enable the claim you want to use (e.g., "client_id"). This instructs Cognito to include the client ID in the token claims.
-
Using API Gateway Mapping Template (Alternative): Cognito Authorizer with Custom Headers: Configure the Cognito authorizer in API Gateway to add a custom header to the request object passed to your Lambda function. This header can contain the client ID extracted from the token by the authorizer. Access Header in Lambda: Your Lambda function can access the custom header containing the client ID using the event.headers dictionary.
Relevant content
- asked 3 years ago
