In AWS API gateway, I am using custom lambda authorizer to validate request headers. I need to update the existing headers or add new ones based on the validation result. Below is the lambda authorizer logic in java, validation works as expected. Irrespective of updating the header values, the event object received in backend lambda is empty.
@Override
public AuthPolicy handleRequest(APIGatewayProxyRequestEvent event, Context context) {
LambdaLogger logger = context.getLogger();
logger.log("Loading Java Lambda handler of Proxy");
logger.log("Event Object : " + event.toString());
Pattern requestIdpattern = Pattern.compile("[0-9a-f]{4}-[0-9A-Z]{3}");
ProxyRequestContext reqContext = event.getRequestContext();
boolean isValid = false;
Map<String, String> headers = event.getHeaders();
if (requestIdpattern.matcher(headers.get("x-request-id")).matches()) {
isValid = true;
headers.put("x-jid", UUID.randomUUID().toString());
}
if (isValid) {
AuthPolicy authPolicy = new AuthPolicy("XXXX",
PolicyDocument.getAllowPolicy("us-east-1", reqContext.getAccountId(), reqContext.getApiId(),
reqContext.getStage(), HttpMethod.getHttpMethod(reqContext.getHttpMethod()),
reqContext.getResourcePath()));
return authPolicy;
} else {
AuthPolicy authPolicy = new AuthPolicy("XXXXXX",
PolicyDocument.getDenyPolicy("us-east-1", reqContext.getAccountId(), reqContext.getApiId(),
reqContext.getStage(), HttpMethod.getHttpMethod(reqContext.getHttpMethod()),
reqContext.getResourcePath()));
logger.log("Auth Policy Response Object : " + authPolicy.toString());
return authPolicy;
}
}
Could you please let me know how to configure the authorizer such that input request to API gateway request should be sent to integration service after successfully authorized.