'Authentication with resque web sinatra app in Rails app

I am in the process of updated resque in my rails app from 1.27 to 2.2. In doing so, I'm removing the resque-web gem and will be using the native sinatra-based resque server. In the past with resque-web, I've been able to add a layer of authorization/authentication on top of access to the resque web UI by adding something like the following to my app initializers:

::ResqueWeb::ApplicationController.include MyAuthorization::AuthenticationHelper
::ResqueWeb::ApplicationController.before_action :authenticate_and_authorize!

Where MyAuthorization::AuthenticationHelper is a standard helper class defined in my rails app, in which the authenticate_and_authorize! method is defined, and uses the standard rails controller request/session/controller classes. Finally, I'm mounting the ResqueWeb engine in my routes.rb like like this:

Rails.application.routes.draw do
  mount ResqueWeb::Engine => "/resque_web"
  ...

Now that I've moved to using the Sinatra-based server, there's no before_action that I can "hook into" to setup authentication/authorization, so I'm kind of at a loss for where to begin. I feel like I've gone down a rabbit hole, massaging sinatra requests to "look like" rails requests, but I feel like it's just needlessly complicating things. Does anyone have experience adding auth to the resque_web server in a rails environment?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source