aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/action_mailbox/base_controller.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/action_mailbox/base_controller.rb b/app/controllers/action_mailbox/base_controller.rb
index a64a817b51..d3846b06e1 100644
--- a/app/controllers/action_mailbox/base_controller.rb
+++ b/app/controllers/action_mailbox/base_controller.rb
@@ -4,12 +4,17 @@ class ActionMailbox::BaseController < ActionController::Base
private
def authenticate
if username.present? && password.present?
- authenticate_or_request_with_http_basic("Action Mailbox") do |given_username, given_password|
- ActiveSupport::SecurityUtils.secure_compare(given_username, username) &
- ActiveSupport::SecurityUtils.secure_compare(given_password, password)
- end
+ http_basic_authenticate_or_request_with username: username, password: password, realm: "Action Mailbox"
else
raise ArgumentError, "Missing required ingress credentials"
end
end
+
+ # TODO: Extract to ActionController::HttpAuthentication
+ def http_basic_authenticate_or_request_with(username:, password:, realm: nil)
+ authenticate_or_request_with_http_basic(realm || "Application") do |given_username, given_password|
+ ActiveSupport::SecurityUtils.secure_compare(given_username, username) &
+ ActiveSupport::SecurityUtils.secure_compare(given_password, password)
+ end
+ end
end