mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Restore class-level middleware APIs for backwards compat, fixes #4821
This commit is contained in:
parent
f0ddebc740
commit
50740f253e
3 changed files with 15 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
HEAD
|
||||
---------
|
||||
|
||||
- Add process/thread stats to Busy page [#4806]
|
||||
- Refactor Web UI session usage. [#4804]
|
||||
Numerous people have hit "Forbidden" errors and struggled with Sidekiq's
|
||||
Web UI session requirement. If you have code in your initializer for
|
||||
|
@ -29,9 +30,8 @@ If this is a bare Rack app, use a session middleware before Sidekiq::Web:
|
|||
use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
|
||||
run Sidekiq::Web
|
||||
```
|
||||
- Add process/thread count summary to Busy page [#4806]
|
||||
|
||||
6.1.3
|
||||
6.1.3
|
||||
---------
|
||||
|
||||
- Warn if Redis is configured to evict data under memory pressure [#4752]
|
||||
|
|
|
@ -63,6 +63,14 @@ module Sidekiq
|
|||
opts.each { |key| set(key, false) }
|
||||
end
|
||||
|
||||
def middlewares
|
||||
@middlewares ||= []
|
||||
end
|
||||
|
||||
def use(*args, &block)
|
||||
middlewares << [args, block]
|
||||
end
|
||||
|
||||
def set(attribute, value)
|
||||
send(:"#{attribute}=", value)
|
||||
end
|
||||
|
@ -89,7 +97,7 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def middlewares
|
||||
@middlewares ||= []
|
||||
@middlewares ||= self.class.middlewares
|
||||
end
|
||||
|
||||
def use(*args, &block)
|
||||
|
@ -129,18 +137,11 @@ module Sidekiq
|
|||
extension.registered(WebApplication)
|
||||
end
|
||||
|
||||
def default_middlewares
|
||||
@default ||= [
|
||||
[[Sidekiq::Web::CsrfProtection]],
|
||||
[[Rack::ContentLength]]
|
||||
]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build
|
||||
klass = self.class
|
||||
m = middlewares + default_middlewares
|
||||
m = middlewares
|
||||
|
||||
::Rack::Builder.new do
|
||||
%w[stylesheets javascripts images].each do |asset_dir|
|
||||
|
@ -150,7 +151,7 @@ module Sidekiq
|
|||
end
|
||||
|
||||
m.each { |middleware, block| use(*middleware, &block) }
|
||||
|
||||
use Sidekiq::Web::CsrfProtection unless $TESTING
|
||||
run WebApplication.new(klass)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ describe Sidekiq::Web do
|
|||
|
||||
before do
|
||||
Sidekiq.redis {|c| c.flushdb }
|
||||
app.default_middlewares.clear
|
||||
app.middlewares.clear
|
||||
end
|
||||
|
||||
class WebWorker
|
||||
|
@ -767,7 +767,7 @@ describe Sidekiq::Web do
|
|||
app
|
||||
end
|
||||
|
||||
it 'requires basic authentication' do
|
||||
it 'requires uses session options' do
|
||||
get '/'
|
||||
|
||||
session_options = last_request.env['rack.session'].options
|
||||
|
|
Loading…
Reference in a new issue