How can I password-protect my /sidekiq route (i.e. require authentication for the Sidekiq::Web tool)?

前端 未结 8 1277
太阳男子
太阳男子 2021-02-01 00:52

I am using sidekiq in my rails application. By Default, Sidekiq can be accessed by anybody by appending \"/sidekiq\" after the url. I want to password protect / authenticate onl

8条回答
  •  太阳男子
    2021-02-01 01:18

    Sorry to late to the party, but Sidekiq's wiki recommends the following for Devise:

    To allow any authenticated User:

    # config/routes.rb
    authenticate :user do
      mount Sidekiq::Web => '/sidekiq'
    end
    

    To restrict access to User.admin?

    # config/routes.rb
    authenticate :user, lambda { |u| u.admin? } do
      mount Sidekiq::Web => '/sidekiq'
    end
    

    This wiki post also has many other security schemes.

    This was tested using Rails 5.1.3, Devise 4.3 and Sidekiq 5.0

提交回复
热议问题