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

Support custom HTTP header for IP address source #215

Merged

Conversation

cevantes
Copy link
Contributor

@cevantes cevantes commented Jul 2, 2024

The case here is we use a proxy which replaces X-Real-IP with something not real and instead provides client's IP address via a custom header.

@kazu-yamamoto
Copy link
Owner

@cevantes Gentle ping.

@cevantes
Copy link
Contributor Author

This works in our app now, but I am thinking maybe the new constructor should take an ordered list of custom headers, so that if one is missing it falls back to the next one, what do you think? Also my problem could be mitigated by altering nginx settings or Middleware but that's out of scope for this PR, just saying for posterity.

@kazu-yamamoto
Copy link
Owner

Sorry for the delay.
I was on vacation.
Would you show me the code for the new constructor?

@cevantes cevantes force-pushed the feature/custom-source-header branch from 50b48a4 to 079f294 Compare July 23, 2024 08:22
@cevantes
Copy link
Contributor Author

Sure, here we go

@kazu-yamamoto
Copy link
Owner

The code is OK.
But I don't think this is a breaking change.
So, I would still suggest v2.4.1

@cevantes cevantes force-pushed the feature/custom-source-header branch from 079f294 to 7c772de Compare July 24, 2024 08:46
@cevantes
Copy link
Contributor Author

Sure, updated

@kazu-yamamoto kazu-yamamoto self-requested a review July 24, 2024 21:54
Copy link
Owner

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

LGTM

wai-logger/wai-logger.cabal Outdated Show resolved Hide resolved
@kazu-yamamoto kazu-yamamoto merged commit 3b02012 into kazu-yamamoto:main Jul 24, 2024
@kazu-yamamoto
Copy link
Owner

Merged.
The new version has been released.
Thanks!

@cevantes cevantes deleted the feature/custom-source-header branch July 25, 2024 08:27
Comment on lines +41 to +42
-- | From a custom HTTP header, useful in proxied environment.
| FromHeaderCustom [HeaderName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Since IPAddrSource is exposed to the user, I believe the addition of a data constructor should have caused a MAJOR version bump, at least according to the PVP.

So the new version should have become 2.5, not 2.4.1.

(Apologies for the noise if wai-logger is not actually following the PVP on this!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I think you're right, while this is not a breaking change by intention, the compiler should complain about a missing pattern matching case, which could result in a build failure.

Copy link
Contributor

@cdepillabout cdepillabout Oct 3, 2024

Choose a reason for hiding this comment

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

Ah yeah, just to be clear, in point 1 in https://pvp.haskell.org/#version-numbers, it says:

Breaking change. If any entity was removed, or the types of any entities or the definitions of datatypes or classes were changed, or orphan instances were added or any instances were removed, then the new A.B MUST be greater than the previous A.B.

(emphasis mine)

Here, A.B. is referring to the MAJOR version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's a common pitfall and some library authors choose to hide their constructors and instead expose set functions, which is a bit annoying but helps to avoid a major version bump.

Copy link
Owner

Choose a reason for hiding this comment

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

So, should I deprecate 2.4.1 on Hackage and release it as 2.5?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kazu-yamamoto I believe that is correct.

@kazu-yamamoto
Copy link
Owner

I'm going to review and merge #218 and release v2.5.

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.

3 participants