Skip to content

Commit 1e73813

Browse files
committed
Make mission control only accessible for staff members
1 parent 6ed55a6 commit 1e73813

File tree

7 files changed

+52
-5
lines changed

7 files changed

+52
-5
lines changed

app/controllers/admin/stats_controller.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
class Admin::StatsController < AdminController
2-
disallow_account_scope
3-
42
layout "public"
53

64
def show
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class AdminController < ApplicationController
2+
disallow_account_scope
23
before_action :ensure_staff
34
end

config/application.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ class Application < Rails::Application
2424
config.generators do |g|
2525
g.orm :active_record, primary_key_type: :uuid
2626
end
27+
28+
config.mission_control.jobs.http_basic_auth_enabled = false
2729
end
2830
end
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
Rails.application.config.before_initialize do
2-
# We don't want normal tenanted authentication on mission control.
3-
# Note that we're using HTTP basic auth configured via credentials.
4-
MissionControl::Jobs.base_controller_class = "ActionController::Base"
2+
MissionControl::Jobs.base_controller_class = "AdminController"
53
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require "test_helper"
2+
3+
class Admin::MissionControlTest < ActionDispatch::IntegrationTest
4+
test "staff can access mission control jobs" do
5+
sign_in_as :david
6+
7+
untenanted do
8+
get "/admin/jobs"
9+
end
10+
11+
assert_response :success
12+
end
13+
14+
test "non-staff cannot access mission control jobs" do
15+
sign_in_as :jz
16+
17+
untenanted do
18+
get "/admin/jobs"
19+
end
20+
21+
assert_response :forbidden
22+
end
23+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require "test_helper"
2+
3+
class Admin::StatsControllerTest < ActionDispatch::IntegrationTest
4+
test "staff can access stats" do
5+
sign_in_as :david
6+
7+
untenanted do
8+
get admin_stats_url
9+
end
10+
11+
assert_response :success
12+
end
13+
14+
test "non-staff cannot access stats" do
15+
sign_in_as :jz
16+
17+
untenanted do
18+
get admin_stats_url
19+
end
20+
21+
assert_response :forbidden
22+
end
23+
end

test/fixtures/identities.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
david:
22
email_address: david@37signals.com
3+
staff: true
34

45
jz:
56
email_address: jz@37signals.com
67

78
kevin:
89
email_address: kevin@37signals.com
10+
staff: true
911

1012
mike:
1113
email_address: mike@37signals.com

0 commit comments

Comments
 (0)