Module: Otto::Privacy::Core
- Included in:
- Otto
- Defined in:
- lib/otto/privacy/core.rb
Overview
Core privacy configuration methods included in the Otto class. Provides the public API for configuring IP privacy features.
Instance Method Summary collapse
-
#configure_ip_privacy(octet_precision: nil, hash_rotation: nil, geo: nil, redis: nil, correlation_secret: nil, geo_header: nil, geo_db_path: nil, geo_db_reader: nil, profile: nil) ⇒ Object
Configure IP privacy settings.
-
#disable_ip_privacy! ⇒ Object
Disable IP privacy to access original IP addresses.
-
#enable_full_ip_privacy! ⇒ void
Enable full IP privacy (mask ALL IPs including private/localhost).
Instance Method Details
#configure_ip_privacy(octet_precision: nil, hash_rotation: nil, geo: nil, redis: nil, correlation_secret: nil, geo_header: nil, geo_db_path: nil, geo_db_reader: nil, profile: nil) ⇒ Object
Configure IP privacy settings
Privacy is enabled by default. Use this method to customize privacy behavior without disabling it entirely.
rubocop:disable Metrics/ParameterLists – a keyword-only configuration method; the options are self-documenting at the call site and grouping them into a hash would only obscure the supported settings.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/otto/privacy/core.rb', line 103 def configure_ip_privacy(octet_precision: nil, hash_rotation: nil, geo: nil, redis: nil, correlation_secret: nil, geo_header: nil, geo_db_path: nil, geo_db_reader: nil, profile: nil) # rubocop:enable Metrics/ParameterLists ensure_not_frozen! config = @security_config.ip_privacy_config knobs = { profile: profile, octet_precision: octet_precision, hash_rotation: hash_rotation, geo: geo, correlation_secret: correlation_secret, redis: redis } # Dry-run the assignments on a throwaway copy and validate the combined # result there, so a rejected knob (octet_precision: 7 after a profile # preset, say) raises before the live config has been touched — the # call is all-or-nothing, never half-applied. apply_privacy_knobs(config.dup, knobs).validate! apply_privacy_knobs(config, knobs) apply_geo_config(config, geo: geo, geo_header: geo_header, geo_db_path: geo_db_path, geo_db_reader: geo_db_reader) end |
#disable_ip_privacy! ⇒ Object
Disable IP privacy to access original IP addresses
IMPORTANT: By default, Otto masks public IP addresses for privacy. Private/localhost IPs (127.0.0.0/8, 10.0.0.0/8, etc.) are never masked. Only disable this if you need access to original public IPs.
When disabled: - env[‘REMOTE_ADDR’] contains the real IP address - env[‘otto.original_ip’] also contains the real IP - No PrivateFingerprint is created
23 24 25 26 |
# File 'lib/otto/privacy/core.rb', line 23 def disable_ip_privacy! ensure_not_frozen! @security_config.ip_privacy_config.disable! end |
#enable_full_ip_privacy! ⇒ void
This method returns an undefined value.
Enable full IP privacy (mask ALL IPs including private/localhost)
By default, Otto exempts private and localhost IPs from masking for better development experience. Call this method to mask ALL IPs regardless of type.
41 42 43 44 |
# File 'lib/otto/privacy/core.rb', line 41 def enable_full_ip_privacy! ensure_not_frozen! @security_config.ip_privacy_config.mask_private_ips = true end |