[refs #510] Resque sinatra app secure
This commit is contained in:
parent
38b55d769f
commit
526bdbe60f
|
@ -27,6 +27,8 @@ class Ability
|
||||||
else # Registered user rights
|
else # Registered user rights
|
||||||
if user.admin?
|
if user.admin?
|
||||||
can :manage, :all
|
can :manage, :all
|
||||||
|
# Resque authorize
|
||||||
|
can :manage, Resque
|
||||||
# Protection
|
# Protection
|
||||||
cannot :approve, RegisterRequest, :approved => true
|
cannot :approve, RegisterRequest, :approved => true
|
||||||
cannot :reject, RegisterRequest, :rejected => true
|
cannot :reject, RegisterRequest, :rejected => true
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# config/initializers/admin.rb
|
||||||
|
class CanAccessResque
|
||||||
|
def self.matches?(request)
|
||||||
|
current_user = request.env['warden'].user
|
||||||
|
return false if current_user.blank?
|
||||||
|
Ability.new(current_user).can? :manage, Resque
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,12 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
Rosa::Application.routes.draw do
|
Rosa::Application.routes.draw do
|
||||||
|
require 'resque/server'
|
||||||
|
namespace :admin do
|
||||||
|
constraints CanAccessResque do
|
||||||
|
mount Resque::Server, at: 'resque'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
devise_scope :users do
|
devise_scope :users do
|
||||||
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue