File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 11require "active_support/core_ext/integer/time"
2+ require_relative "../../lib/host_patterns"
23
34Rails . application . configure do
45 # Settings specified here will take precedence over those in config/application.rb.
7273 config . active_support . report_deprecations = false
7374
7475 # Enable DNS rebinding protection and other `Host` header attacks.
75- # config.hosts = [
76- # "example.com", # Allow requests from example.com
77- # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
78- # ]
79- #
76+ config . hosts = HostPatterns . allowed_host_patterns
77+
8078 # Skip DNS rebinding protection for the default health check endpoint.
81- # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
79+ config . host_authorization = { exclude : -> ( request ) { request . path == "/up" } }
8280
8381 # Set ActiveRecord Encryption keys
8482 if ENV . key? "KMS_KEY_ID"
Original file line number Diff line number Diff line change 1+ module HostPatterns
2+ DEFAULT_HOST_PATTERNS = [
3+ /submit\. forms\. service\. gov\. uk/ ,
4+ /submit\. [^.]*\. forms\. service\. gov\. uk/ ,
5+ /submit\. internal.[^.]*\. forms\. service\. gov\. uk/ ,
6+ /pr-[^.]*\. submit\. review\. forms\. service\. gov\. uk/ ,
7+ ] . freeze
8+
9+ def self . allowed_host_patterns
10+ additional_patterns = ENV . fetch ( "ALLOWED_HOST_PATTERNS" , "" ) . split ( "," ) . map { |pattern | Regexp . new ( pattern . strip ) }
11+
12+ [ *DEFAULT_HOST_PATTERNS , *additional_patterns ]
13+ end
14+ end
You can’t perform that action at this time.
0 commit comments