2

I have to add few http headers mapped to the context values comes from the lambda authorizer as shown below

"context": {
    "company_id": "xxxxx-xxx-xxxxxx",
    "Owner":"xxxxx",
  }

and the headers will be sent to the minimal api.

Can anyone help me on the cdk code(.ts) that send the custom headers to the .net api.

Nirmal
  • 61
  • 9
  • 1
    have you been able to fix it? I have the exact same problem. I need to inject some headers with values coming in the JWT payload. – rmpt Sep 08 '22 at 15:58
  • @rmpt Yes, I have taken the context values from the httpcontext in my API – Nirmal Sep 10 '22 at 13:43
  • was it custom claims or other values? I can access "normal" values through `$context.authorizer.claims.whatever`, but I want to access some custom claims, specifically `custom:api_key`, but cdk complains about the `:`. I'm using HttpApi with HttpAlbIntegration to do this (with parameterMapping). – rmpt Sep 12 '22 at 21:01
  • try the below code to get context from the aws authorizer and the below code is in c# `if (httpContext.User.Identities.FirstOrDefault().Claims.Count() > 0) { foreach (var header in httpContext.User.Identities.FirstOrDefault().Claims.Select(x => x)) { switch (header.Type.ToLower()) { case "ownertype":ownerType = header.Value; break; } } }` – Nirmal Sep 15 '22 at 06:51

0 Answers0