1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionmailbox/app/controllers/action_mailbox/base_controller.rb
George Claghorn f480cfabcd
Remove the Amazon SES ingress
It's unusable and not ready to ship in Rails 6.0. We'll rewrite it for 6.1.
2019-04-14 12:15:54 -04:00

34 lines
994 B
Ruby

# frozen_string_literal: true
module ActionMailbox
# The base class for all Action Mailbox ingress controllers.
class BaseController < ActionController::Base
skip_forgery_protection if default_protect_from_forgery
before_action :ensure_configured
private
def ensure_configured
unless ActionMailbox.ingress == ingress_name
head :not_found
end
end
def ingress_name
self.class.name.remove(/\AActionMailbox::Ingresses::/, /::InboundEmailsController\z/).underscore.to_sym
end
def authenticate_by_password
if password.present?
http_basic_authenticate_or_request_with name: "actionmailbox", password: password, realm: "Action Mailbox"
else
raise ArgumentError, "Missing required ingress credentials"
end
end
def password
Rails.application.credentials.dig(:action_mailbox, :ingress_password) || ENV["RAILS_INBOUND_EMAIL_PASSWORD"]
end
end
end