class Lucky::RemoteIpHandler
- Lucky::RemoteIpHandler
- Reference
- Object
Overview
Sets the HTTP::Request#remote_address value as Socket::IPAddress?
to the value of the last IP in the X-Forwarded-For
header, or fallback to the default remote_address
.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
This will also set a remote_ip
String value as String
which will be
either the raw remote_address
value, or an empty string.
This Handler does a "best guess" for the IP which is generally good enough. If you require IP based Authentication, then you may want to handle this on your own as there will be edge cases when related to mobile clients on the go, and potential IP spoofing attacks. More detailed info: https://adam-p.ca/blog/2022/03/x-forwarded-for/
Included Modules
- Habitat::SettingsHelpers
- Habitat::TempConfig
- HTTP::Handler
Defined in:
lucky/remote_ip_handler.crConstant Summary
-
HABITAT_SETTINGS =
[{decl: ip_header_name : String = "X-Forwarded-For", example: nil, validation: nil}] of Nil