我正在尝试用Devise保护Sidekiq UI。我正在运行Rails 5.1,Devise 4.3和Sidekiq 5.0。我尝试了以下帖子:
但是我收到以下错误:
Undefined method failure_app for nil:NilClass
我的路线文件如下所示:
Rails.application.routes.draw do
constraint = lambda do |request|
request.env['warden'].authenticate!({ scope: :admin_user })
end
constraints constraint do
mount Sidekiq::Web => '/admin/sidekiq'
end
devise_for :users
resources :users
end
如何使用Devise on Rails 5.1保护Sidekiq UI?
答案 0 :(得分:1)
我偶然发现了page,其中概述了如何使用Devise保护Web UI:
Devise
Allow any authenticated User
# Allow any user access
authenticate :user do
mount Sidekiq::Web => '/sidekiq'
end
# Allow only admin users
authenticate :user, lambda { |u| u.admin? } do
mount Sidekiq::Web => '/sidekiq'
end
我已经确认这适用于Rails 5.1和Devise 4.3。