Skip to content

Commit c9ac7bb

Browse files
committed
Fixes #38120 - Support Sinatra 4 and Rack 3
1 parent 156e1e9 commit c9ac7bb

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎lib/launcher.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'openssl'
2+
require 'rackup/handler/webrick'
23
require 'proxy/log'
34
require 'proxy/settings'
45
require 'proxy/signal_handler'
@@ -191,7 +192,7 @@ def webrick_server(app, addresses, port)
191192
rescue ::OpenSSL::SSL::SSLError => e
192193
raise "Invalid tls_ciphers value '#{app[:SSLCiphers]}': #{e.message}"
193194
end
194-
server.mount "/", Rack::Handler::WEBrick, app[:app]
195+
server.mount "/", Rackup::Handler::WEBrick, app[:app]
195196

196197
# WEBrick 1.9.x does not support :SSLMinVersion in its config hash, so we
197198
# apply min_version= directly on the SSL context after WEBrick creates it.

‎lib/proxy/hsts_middleware.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def initialize(app)
1010

1111
def call(env)
1212
status, headers, body = @app.call(env)
13-
if env['HTTPS'] == 'on' && !headers.include?('Strict-Transport-Security')
14-
headers['Strict-Transport-Security'] = 'max-age=31536000'
13+
if env['HTTPS'] == 'on' && !headers.include?('strict-transport-security')
14+
headers['strict-transport-security'] = 'max-age=31536000'
1515
end
1616
[status, headers, body]
1717
end

‎modules/registration/registration_api.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
require 'registration/proxy_request'
22

33
class Proxy::Registration::Api < ::Sinatra::Base
4+
# Needed so `logger` resolves to Proxy::LogBuffer::Decorator (which implements
5+
# #exception, used in the rescue blocks below) instead of Sinatra's own null
6+
# logger, which is a plain ::Logger with no #exception method as of Sinatra 4.
7+
helpers ::Proxy::Helpers
8+
49
# Cache for the global registration script (GET /register).
510
#
611
# The script is identical for all hosts sharing the same registration

‎smart_proxy.gemspec‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Gem::Specification.new do |s|
1717
s.add_dependency 'json'
1818
s.add_dependency 'logging'
1919
s.add_dependency 'ostruct'
20-
s.add_dependency 'rack', '>= 1.3'
20+
s.add_dependency 'rack', '>= 3.0', '< 4'
21+
s.add_dependency 'rackup', '~> 2.0'
2122
s.add_dependency 'rexml', '~> 3.2'
2223
s.add_dependency 'sd_notify', '~> 0.1'
23-
s.add_dependency 'sinatra', '~> 2.0'
24+
s.add_dependency 'sinatra', '~> 4.0'
2425
s.add_dependency 'webrick', '~> 1.0'
2526
s.description = <<~EOF
2627
Foreman Proxy is used via The Foreman Project, it allows Foreman to manage

0 commit comments

Comments
 (0)