Commit 2da45e9cbf8bf0db88274451ba9dc61db50c571d
1 parent
3a4aff69
Exists in
master
and in
4 other branches
Refs #1013
Renamed protect_resque.rb => resque_authentication Integrated resque web with the rest of gitlab
Showing
7 changed files
with
28 additions
and
11 deletions
Show diff stats
app/views/admin/dashboard/index.html.haml
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | %h5 | 4 | %h5 |
| 5 | Resque Workers | 5 | Resque Workers |
| 6 | .data.padded | 6 | .data.padded |
| 7 | - = link_to "/info/resque" do | 7 | + = link_to admin_resque_path do |
| 8 | %h1{:class => @workers.present? ? "cgreen" : "cred"} | 8 | %h1{:class => @workers.present? ? "cgreen" : "cred"} |
| 9 | = @workers.count | 9 | = @workers.count |
| 10 | %hr | 10 | %hr |
app/views/layouts/admin.html.haml
| @@ -6,10 +6,10 @@ | @@ -6,10 +6,10 @@ | ||
| 6 | = render "layouts/head_panel", :title => "Admin area" | 6 | = render "layouts/head_panel", :title => "Admin area" |
| 7 | .container | 7 | .container |
| 8 | %nav.main_menu | 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 | .content= yield | 15 | .content= yield |
config/initializers/protect_resque.rb
| @@ -0,0 +1,14 @@ | @@ -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 | \ No newline at end of file | 15 | \ No newline at end of file |
config/routes.rb
| @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do | @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do | ||
| 38 | get 'mailer/preview_note' | 38 | get 'mailer/preview_note' |
| 39 | get 'mailer/preview_user_new' | 39 | get 'mailer/preview_user_new' |
| 40 | get 'mailer/preview_issue_new' | 40 | get 'mailer/preview_issue_new' |
| 41 | + resource :resque, :controller => 'resque' | ||
| 41 | root :to => "dashboard#index" | 42 | root :to => "dashboard#index" |
| 42 | end | 43 | end |
| 43 | 44 |