From 4b31f166dd2a0bf3198a4f6f67c156b2dc98c7b2 Mon Sep 17 00:00:00 2001 From: Christian Sutter Date: Mon, 20 Nov 2023 10:13:57 +0000 Subject: [PATCH] Enable basic auth when appropriate env present --- app/controllers/application_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..f0dc380 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,8 @@ class ApplicationController < ActionController::Base + if ENV["BASIC_AUTH_USERNAME"] && ENV["BASIC_AUTH_PASSWORD"] + http_basic_authenticate_with( + name: ENV.fetch("BASIC_AUTH_USERNAME"), + password: ENV.fetch("BASIC_AUTH_PASSWORD"), + ) + end end