Module: LogStruct::Integrations::HostAuthorization
- Extended by:
- IntegrationInterface, T::Sig
- Defined in:
- lib/log_struct/integrations/host_authorization.rb
Overview
Host Authorization integration for structured logging of blocked hosts
Defined Under Namespace
Classes: ResponseApp
Constant Summary collapse
- RESPONSE_HTML =
T.let( "<html><head><title>Blocked Host</title></head><body>" \ "<h1>Blocked Host</h1>" \ "<p>This host is not permitted to access this application.</p>" \ "<p>If you are the administrator, check your configuration.</p>" \ "</body></html>", String )
- RESPONSE_HEADERS =
T.let( { "Content-Type" => "text/html", "Content-Length" => RESPONSE_HTML.bytesize.to_s }.freeze, T::Hash[String, String] )
- FORBIDDEN_STATUS =
T.let(403, Integer)
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up host authorization logging.
Methods included from IntegrationInterface
Class Method Details
.setup(config) ⇒ Boolean?
Set up host authorization logging
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/log_struct/integrations/host_authorization.rb', line 34 def self.setup(config) return nil unless config.enabled return nil unless config.integrations. # Merge our response_app into existing host_authorization config to preserve excludes existing = Rails.application.config. unless existing.is_a?(Hash) existing = {} end existing = existing.dup app_response_app = existing[:response_app] # Set up once: don't wrap our own response app again app_response_app = app_response_app.app_response_app if app_response_app.is_a?(ResponseApp) existing[:response_app] = ResponseApp.new(app_response_app) Rails.application.config. = existing true end |