FEATURE: only allow sidekiq in master site when hosted on multisite

This commit is contained in:
Sam Saffron 2016-03-17 00:26:07 +11:00
parent b300d60086
commit e84d5549ef
2 changed files with 7 additions and 1 deletions

View File

@ -20,7 +20,8 @@ Discourse::Application.routes.draw do
mount Sidekiq::Web => "/sidekiq"
mount Logster::Web => "/logs"
else
mount Sidekiq::Web => "/sidekiq", constraints: AdminConstraint.new
# only allow sidekie in master site
mount Sidekiq::Web => "/sidekiq", constraints: AdminConstraint.new(require_master: true)
mount Logster::Web => "/logs", constraints: AdminConstraint.new
end

View File

@ -2,7 +2,12 @@ require_dependency 'current_user'
class AdminConstraint
def initialize(options={})
@require_master = options[:require_master]
end
def matches?(request)
return false if @require_master && RailsMultisite::ConnectionManagement.current_db != "default"
provider = Discourse.current_user_provider.new(request.env)
provider.current_user && provider.current_user.admin?
end