diff options
author | George Claghorn <george@basecamp.com> | 2018-10-29 14:19:46 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-10-29 14:19:46 -0400 |
commit | cb041ddc7e94da15e2db72188545f78da6cadb53 (patch) | |
tree | 7e6210295cc78232f397f4d35782108e5b1e0267 /app/controllers | |
parent | be0a8bec8701c7df2667dbf1569429218ea30370 (diff) | |
download | rails-cb041ddc7e94da15e2db72188545f78da6cadb53.tar.gz rails-cb041ddc7e94da15e2db72188545f78da6cadb53.tar.bz2 rails-cb041ddc7e94da15e2db72188545f78da6cadb53.zip |
Stage an Action Controller extraction
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/action_mailbox/base_controller.rb | 13 |
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 |