Sidekiq Monitoring Authentication With Devise on Ruby on Rails

Sidekiq Monitoring displays the information of works in the background. This screen is very useful in our business development and production environment. But we may want protect access to this information. We can use the devise authentication of routing:

Allow a authenticated user:

We can change the routing as below:

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

Also we can use the condition as below(Condition result must be to access sidekiq monitoring page).

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

We can use role methods for user object if roles defined as enum in user model.

For Example:

# app/models/user.rb
class User < ActiveRecord::Base
 enum role: [:user, :moderator, :admin, :system_admin]
end
# config/routes.rb
authenticate :user, lambda { |user| user.admin? or user.system_admin? } do
mount Sidekiq::Web => '/sidekiq'
end

Thank you for reading.

Sertan aka Kolonel Max.

Advertisements

One thought on “Sidekiq Monitoring Authentication With Devise on Ruby on Rails

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s