Sha256: 9ebb371d00fa8124378bc9464fc5984085ae6b926b7accba833109bb29bc06ce
Contents?: true
Size: 590 Bytes
Versions: 3
Compression:
Stored size: 590 Bytes
Contents
module IpAnonymizer class HashIp def initialize(app, key:) @app = app @key = key end def call(env) req = ActionDispatch::Request.new(env) # get header directly to preserve ActionDispatch::RemoteIp lazy loading req.remote_ip = GetIp.new(req.get_header("action_dispatch.remote_ip".freeze), @key) @app.call(req.env) end class GetIp def initialize(remote_ip, key) @remote_ip = remote_ip @key = key end def to_s @ip ||= IpAnonymizer.hash_ip(@remote_ip, key: @key) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ip_anonymizer-0.3.0 | lib/ip_anonymizer/hash_ip.rb |
ip_anonymizer-0.2.0 | lib/ip_anonymizer/hash_ip.rb |
ip_anonymizer-0.1.1 | lib/ip_anonymizer/hash_ip.rb |