aws-samples/cloudfront-authorization-at-edge

Missing User-Agent header in Post request to cognito

abcJo opened this issue · 4 comments

When using a Congito User Pool with a WAF attached the following scenario occurs:
The post request to exchange the authorization token to Cognito /oauth/token endpoint is blocked by a WAF that contains the AWS managed rule AWSManagedRulesCommonRuleSet.
Specifically, the NoUserAgent_HEADER rule blocks the request.

Is it possible to update the request configurations, so that the User-Agent header is set?

Sure thing, wanna send a PR?

Just inject a default user agent header option here:

return await fetch(url, data, {
agent: AGENT,
...options,
method: "POST",
}).then((res) => {

Great.
I'd love to, however, I'm not at all familiar with typescript.
It's probably much faster if you could do it :)
Thanks!

No worries, but I don't know when I'll have bandwidth for it.

Hi @ottokruse @abcJo , I opened a PR for the same #282