Mapping multiple headers in an API GatewayV2 HTTP API to a single header for use in a custom Lambda Authorizer as Identity Source

0

I have an HTTP ApiGatewayV2 setup, with a single AWS_PROXY endpoint to a lambda (using HTTP, not REST!). There are 2 sources of incoming requests, one is a frontend we control, and one is a 3rd party api. Both send JWT tokens with the requests, but in different headers. I am using a custom authorizer to validate the JWT tokens, and determine the policies based on the claim. Since I am using an AWS_PROXY with a single route for all requests, I need a single authorizer lambda to handle both tokens/headers. I would like to be able to cache the authorization responses from the authorization lambda, so I want to use the IdentitySource. But since there are 2 different headers that can contain the JWT token, this doesn't work. Unfortunately the Identity source entries need to ALL be present for the lambda to be invoked. So I can't specify ["$request.header.Authorization", "$request.header.OtherHeader"]. So would there be a way to somehow map $request.header.OtherHeader to $request.header.Authorization before the authorization lambda gets invoked? Or is there another trick to achieve something similar? Cheers

1개 답변
0

Mapping happens after authorization, so you can't do what you want in API Gateway.

What you can do is put a CloudFront distribution in front of API gateway and use CloudFront Functions to set the common header.

profile pictureAWS
전문가
Uri
답변함 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠