Skip to content

Commit b43e60e

Browse files
committed
feat: allow rack protection to be turned off so that the headers can be managed in nginx
1 parent 0c8106b commit b43e60e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/pact_broker/app.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def prepare_app
118118

119119
def configure_middleware
120120
# NOTE THAT NONE OF THIS IS PROTECTED BY AUTH - is that ok?
121-
@app_builder.use Rack::Protection, except: [:path_traversal, :remote_token, :session_hijacking, :http_origin]
121+
if configuration.use_rack_protection
122+
@app_builder.use Rack::Protection, except: [:path_traversal, :remote_token, :session_hijacking, :http_origin]
123+
end
122124
@app_builder.use Rack::PactBroker::InvalidUriProtection
123125
@app_builder.use Rack::PactBroker::StoreBaseURL
124126
@app_builder.use Rack::PactBroker::AddPactBrokerVersionHeader

lib/pact_broker/configuration.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Configuration
3232
:base_equality_only_on_content_that_affects_verification_results
3333
]
3434

35-
attr_accessor :log_dir, :database_connection, :auto_migrate_db, :auto_migrate_db_data, :use_hal_browser, :html_pact_renderer
35+
attr_accessor :log_dir, :database_connection, :auto_migrate_db, :auto_migrate_db_data, :use_hal_browser, :html_pact_renderer, :use_rack_protection
3636
attr_accessor :validate_database_connection_config, :enable_diagnostic_endpoints, :version_parser, :sha_generator
3737
attr_accessor :use_case_sensitive_resource_names, :order_versions_by_date
3838
attr_accessor :check_for_potential_duplicate_pacticipant_names
@@ -62,6 +62,7 @@ def self.default_configuration
6262
config.log_dir = File.expand_path("./log")
6363
config.auto_migrate_db = true
6464
config.auto_migrate_db_data = true
65+
config.use_rack_protection = true
6566
config.use_hal_browser = true
6667
config.validate_database_connection_config = true
6768
config.enable_diagnostic_endpoints = true

0 commit comments

Comments
 (0)