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

fix(ip): Set x-forwarded-for header from gql to auth-server #15422

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/fxa-graphql-api/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export const GqlXHeaders = createParamDecorator(
// We don't need to propagate the authorization token because
// it needs to be updated to originate from gql server.
delete headers['authorization'];

// Set the x-forwarded-for header since the auth-server will use this
// to determine client geolocation
if (ctx.req?.ip) {
headers['x-forwarded-for'] = ctx.req?.ip;
Copy link
Member

@clouserw clouserw Jun 7, 2023

Choose a reason for hiding this comment

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

Just to be explicit here, ctx.req.ip does not come from a user-agent, right? (Meaning there is no possibility of injecting something here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call out, this value is populated from Graphql request and not injected.

}

return new Headers(headers);
}
);