Skip to content

Commit 6d57165

Browse files
authored
Merge pull request #3477 from kaitozaw/issue/3091-host-name-validation
Fixes issue/host-name-validation (#3091)
2 parents 0680a51 + cbd9292 commit 6d57165

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/main/router/router.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ class Router < Sinatra::Base
1414

1515
configure do
1616
set :show_exceptions, false
17+
18+
# Configure Rack::Protection::HostAuthorization.
19+
# Allow Rack development defaults and dynamically permit the public host
20+
# defined by beef.http.public.host to prevent "Host not permitted" errors.
21+
permitted = [
22+
'.localhost',
23+
'.test',
24+
IPAddr.new('0.0.0.0/0'),
25+
IPAddr.new('::/0')
26+
]
27+
public_host = config.get('beef.http.public.host').to_s.strip
28+
permitted << public_host unless public_host.empty?
29+
set :host_authorization, { permitted_hosts: permitted }
1730
end
1831

1932
# @note Override default 404 HTTP response

0 commit comments

Comments
 (0)