Skip to content

feat: Support x-forwarded-for headers for IPs #4684

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

Merged
merged 4 commits into from
Oct 23, 2022
Merged

feat: Support x-forwarded-for headers for IPs #4684

merged 4 commits into from
Oct 23, 2022

Conversation

kylecarbs
Copy link
Member

Fixes #4430.

This mostly copies in code from v1, and adds a few tests.

@kylecarbs kylecarbs force-pushed the realip branch 4 times, most recently from 2410a20 to d1c9711 Compare October 21, 2022 17:49
@kylecarbs kylecarbs requested a review from a team as a code owner October 21, 2022 17:49
@kylecarbs kylecarbs requested review from jsjoeio and coadler and removed request for a team October 21, 2022 17:49
@kylecarbs kylecarbs self-assigned this Oct 21, 2022
Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

High-level, looks good to me

@@ -321,6 +322,11 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
}
}

realIPConfig, err := httpmw.ParseRealIPConfig(dflags.ProxyTrustedHeaders.Value, dflags.ProxyTrustedOrigins.Value)
if err != nil {
return xerrors.Errorf("parse real ip config: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: will a use know what real ip config means here? wondering if we can make that friendlier

headerXForwardedProto,
}

// Config configures the search order for the function, which controls
Copy link
Contributor

Choose a reason for hiding this comment

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

impressed with all the comments throughout this!

Copy link
Member

Choose a reason for hiding this comment

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

Jonathan wrote this originally I believe :D

@kylecarbs kylecarbs merged commit f75a54c into main Oct 23, 2022
@kylecarbs kylecarbs deleted the realip branch October 23, 2022 18:21
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audit: Support for x-forwared-for headers to get correct user ips
3 participants