Skip to content

Commit

Permalink
Update delayed_job_web to be accessible by logged in super_admins rat…
Browse files Browse the repository at this point in the history
…her than username/password
  • Loading branch information
edwinthinks committed Jul 18, 2022
1 parent d0b1293 commit a3c256f
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
def set_up_delayed_job
if Rails.env.production?
DelayedJobWeb.use Rack::Auth::Basic do |username, password|
ActiveSupport::SecurityUtils.variable_size_secure_compare(
ENV["DELAYED_JOB_USERNAME"],
username
) &&
ActiveSupport::SecurityUtils.variable_size_secure_compare(
ENV["DELAYED_JOB_PASSWORD"],
password
)
end
end

match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
end

def set_up_flipper
flipper_app = Flipper::UI.app(Flipper.instance) do |builder|
builder.use Rack::Auth::Basic do |username, password|
Expand All @@ -32,7 +15,14 @@ def set_up_flipper
devise_for :partner_users, controllers: { sessions: "partners/sessions", invitations: 'partners/invitations', passwords: 'partners/passwords' }
resources :logins, only: [:new, :create], controller: "consolidated_logins"

set_up_delayed_job
#
# Mount web interface to see delayed job status and queue length.
# Visible only to logged in users with the `super_admin` flag set to true
#
authenticated :user, ->(user) { user.super_admin? } do
mount DelayedJobWeb, at: "/delayed_job"
end

set_up_flipper

# Add route partners/dashboard so that we can define it as partner_user_root
Expand Down

0 comments on commit a3c256f

Please sign in to comment.