class Lucky::RemoteIpHandler

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

Defined in:

lucky/remote_ip_handler.cr

Constant Summary

HABITAT_SETTINGS = [{decl: ip_header_name : String = "X-Forwarded-For", example: nil, validation: nil}] of Nil

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

blank? : Bool blank?, present? : Bool present?

Class Method Detail

def self.configure(&) #

[View source]
def self.settings #

[View source]

Instance Method Detail

def call(context) #

[View source]
def settings #

[View source]