Commit 2da45e9cbf8bf0db88274451ba9dc61db50c571d

Authored by gleb
1 parent 3a4aff69

Refs #1013

Renamed protect_resque.rb => resque_authentication
Integrated resque web with the rest of gitlab
app/controllers/admin/resque_controller.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class Admin::ResqueController < ApplicationController
  2 + layout 'admin'
  3 + def show
  4 + end
  5 +end
0 6 \ No newline at end of file
... ...
app/views/admin/dashboard/index.html.haml
... ... @@ -4,7 +4,7 @@
4 4 %h5
5 5 Resque Workers
6 6 .data.padded
7   - = link_to "/info/resque" do
  7 + = link_to admin_resque_path do
8 8 %h1{:class => @workers.present? ? "cgreen" : "cred"}
9 9 = @workers.count
10 10 %hr
... ...
app/views/admin/resque/show.html.haml 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +%h3 Resque
  2 +%iframe{:src => "/info/resque", :width => 1168, :height => 600, :style => "border: none"}
0 3 \ No newline at end of file
... ...
app/views/layouts/admin.html.haml
... ... @@ -6,10 +6,10 @@
6 6 = render "layouts/head_panel", :title => "Admin area"
7 7 .container
8 8 %nav.main_menu
9   - = link_to "Stats", admin_root_path, :class => "home #{controller.controller_name == "dashboard" ? "current" : nil}"
10   - = link_to "Projects", admin_projects_path, :class => controller.controller_name == "projects" ? "current" : nil
11   - = link_to "Users", admin_users_path, :class => controller.controller_name == "users" ? "current" : nil
12   - = link_to "Emails", admin_emails_path, :class => controller.controller_name == "mailer" ? "current" : nil
13   - = link_to "Resque", "/info/resque"
  9 + = link_to "Stats", admin_root_path, :class => "home #{'current' if controller.controller_name == "dashboard"}"
  10 + = link_to "Projects", admin_projects_path, :class => ('current' if controller.controller_name == "projects")
  11 + = link_to "Users", admin_users_path, :class => ('current' if controller.controller_name == 'users')
  12 + = link_to "Emails", admin_emails_path, :class => ('current' if controller.controller_name == 'mailer')
  13 + = link_to "Resque", admin_resque_path, :class => ('current' if controller.controller_name == 'resque')
14 14  
15 15 .content= yield
... ...
config/initializers/protect_resque.rb
... ... @@ -1,5 +0,0 @@
1   -require 'resque/server'
2   -Resque::Server.use(Rack::Auth::Basic) do |user, password|
3   - user == "gitlab"
4   - password == "5iveL!fe"
5   -end
config/initializers/resque_authentication.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +require 'resque/server'
  2 +class Authentication
  3 + def initialize(app)
  4 + @app = app
  5 + end
  6 +
  7 + def call(env)
  8 + account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user)
  9 + raise "Access denied" if !account.admin?
  10 + @app.call(env)
  11 + end
  12 +end
  13 +
  14 +Resque::Server.use Authentication
0 15 \ No newline at end of file
... ...
config/routes.rb
... ... @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do
38 38 get 'mailer/preview_note'
39 39 get 'mailer/preview_user_new'
40 40 get 'mailer/preview_issue_new'
  41 + resource :resque, :controller => 'resque'
41 42 root :to => "dashboard#index"
42 43 end
43 44  
... ...