How to use Rails SolidQueue Mission Control with Pundit policies?

76 Views Asked by At

I've been using SolidQueue for a bit with good success. Mission Control was just released, so I added that gem and configuration. However, upon visiting the /jobs page I get the following error:

Pundit::PolicyScopingNotPerformedError at /MissionControl::Jobs::QueuesController

Pundit is monitoring the QueuesController for authorization. I don't have access to that controller to skip/define authorization---so, how would I get past this issue? I see it's possible to set the base class for Mission Control's controllers using the 'base_controller_class' config---I attempted this, expecting the error to change but I just get the same error.

I would like to eventually protect /jobs with Pundit. But, first I'd like to the see the /jobs page load successfully. Thanks!

2

There are 2 best solutions below

0
hellion On

This might not be the best solution, but it's working for now.

Since MissionControl inherits from the host apps ApplicationController, I knew I could work around this issue in there. So, in the ApplicationController I created a new method:

  def mission_control_controller?
    is_a?(::MissionControl::Jobs::QueuesController)
  end

Then, I simply call:

skip_after_action :verify_policy_scoped, if: :mission_control_controller?

I don't need to authorize the scope (so, it's safe to skip), I just need to authorize access to the /jobs page/action.

0
Dorian On

I had to do it for verify_authorized and verify_policy_scoped. And use ApplicationController from mission-control_jobs

  skip_after_action :verify_authorized, if: :mission_control_controller?
  skip_after_action :verify_policy_scoped, if: :mission_control_controller?

  def mission_control_controller?
    is_a?(::MissionControl::Jobs::ApplicationController)
  end