Commit f73d71810e4d9fb095d945d8473d2c19d1b0badc
Exists in
master
and in
4 other branches
Merge pull request #1018 from glebm/master
Resque Authentication + iFrame view
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
@@ -50,6 +50,7 @@ Gitlab::Application.routes.draw do | @@ -50,6 +50,7 @@ Gitlab::Application.routes.draw do | ||
50 | get 'mailer/preview_note' | 50 | get 'mailer/preview_note' |
51 | get 'mailer/preview_user_new' | 51 | get 'mailer/preview_user_new' |
52 | get 'mailer/preview_issue_new' | 52 | get 'mailer/preview_issue_new' |
53 | + resource :resque, :controller => 'resque' | ||
53 | root :to => "dashboard#index" | 54 | root :to => "dashboard#index" |
54 | end | 55 | end |
55 | 56 |