Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set default user agent #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sagar-rout
Copy link

#264

if user agent is missing, it provides default agent with default max cached session 50.

@sagar-rout
Copy link
Author

I am sorry, I could not find test cases. So, I didn't start anything new for the same

@ottokruse
Copy link
Collaborator

Hi mate. I believe you want to add the addition of a HTTP header "User-Agent" to the request options. You can leave the AGENT stuff alone (that is for something else, reusing TLS connections but issue #264 is different)

@ottokruse
Copy link
Collaborator

So add standard http header "User-Agent" with value "authorization-at-edge" or so to the options object (RequestOptions)

@sagar-rout
Copy link
Author

sagar-rout commented Jul 22, 2024

I'm sorry. I misunderstood the issue. Thanks for pointing in the right direction. I updated the PR.

@sagar-rout sagar-rout changed the title Set default http agent with max cached sessions of 50 set default user agent Jul 23, 2024
@ottokruse
Copy link
Collaborator

Cheers mate and no worries! Easy to make mistakes

Having looked around a bit, I see the usual format for User-Agent is name/version, e.g. curl/7.64.1 or PostmanRuntime/7.26.5

I like adding the Auth@Edge version in there, so that we e.g. get authorization-at-edge/2.3.0, but it will mean that the Lambda@Edge functions need to know this version. We can make them know, because it is a CloudFormation parameter, that we can inject in the config (in the relevant Custom::LambdaCodeUpdate entries in the CFN template).

If you're up to adding that, go for it.

If that's a bit too much I can understand too let me know.

Question: did you test it like this? Does this indeed work to not run into the WAF rule?

Copy link
Collaborator

@ottokruse ottokruse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run prettier? (code formatting: npx prettier -w .)

@@ -36,8 +36,9 @@ export const handler: CloudFrontRequestHandler = async (event) => {
cookies.refreshToken
);

const headers: { "Content-Type": string; Authorization?: string } = {
const headers: { "Content-Type": string; Authorization?: string; "User-Agent":string } = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just change this type to OutgoingHttpHeaders -- bit annoying to spell all keys we use out like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants