Skip to content

Commit

Permalink
Add custom auth for mission control
Browse files Browse the repository at this point in the history
  • Loading branch information
oneiros committed Feb 19, 2025
1 parent f5cf4d8 commit d98bfbe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/controllers/mission_control_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Base Controller adding custom authentication to mission control
class MissionControlController < ActionController::Base
CREDENTIALS = {
name: ENV["MISSION_CONTROL_USERNAME"],
password: ENV["MISSION_CONTROL_PASSWORD"]
}.freeze

before_action :authenticate

private

def authenticate
if authentication_enabled?
http_basic_authenticate_or_request_with(**CREDENTIALS)
else
head :unauthorized
end
end

def authentication_enabled?
CREDENTIALS.values.all?(&:present?)
end
end
4 changes: 4 additions & 0 deletions config/initializers/mission_control.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Rails.application.configure do
MissionControl::Jobs.base_controller_class = "MissionControlController"
MissionControl::Jobs.http_basic_auth_enabled = false
end

0 comments on commit d98bfbe

Please sign in to comment.