1

I have a scenario where the caller of my services is going to pass a JWT (JSON web token), and I want to pass that value to a custom authorizer that uses lambda function in order to decrypt it and return a policy to that caller where the policy can be allow that user or deny it. in addtion of adding a header value after the lambda completes the JWT decryption.

for Example:

  1. The caller (end user) call a service serviceX(POST/Get).
  2. call reaches AWS API GateWay
  3. Service is marked with authorised method which is custom authorizer
  4. Custom Authorizer calls lambda function
  5. Lambda function decrypt the JWT
  6. Lambda function adds a new header/modify an existing one
  7. end service (serviceX) receives the request

I have implemented all the above example except number 6, I can't add a new header value from lambda or modify an existing one.

I have searched a lot and I can't find a way to do so.

any further documentation or snippets from AWS about this issue I will provide it by request -if needed-.

2
  • What are you using as an integration? HTTP, Lambda, another AWS service? Commented Jan 30, 2017 at 17:47
  • I am using HTTP Commented Jan 31, 2017 at 8:55

1 Answer 1

1

You cannot set a header from the custom authorizer. You can however return a context map of values that you can use in the serviceX function.

So the custom authorizer returns the policy together with a context:

{
    "principalId": "yyyyyyyy",
    "policyDocument": {
        ... blah blah ...
    },
    "context": {
        "customvalue": "response-from-number-6"
    }
}

Then you can access it in the serviceX function in the the following attribute:

$context.authorizer.customvalue

Does that solve your number 6 of returning a value from the custom authorizer?

Sign up to request clarification or add additional context in comments.

2 Comments

are you referring to use the customvalue in the serviceX payload/body ? and I have used this senior to set the customvalue in the serviceX payload, but i need to use this customvalue to add it in the request header. do you have any ideas how to implement this ?
You can use the same syntax $context.authorizer.customvalue to set the value for a request header to serviceX

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.