Sha256: f5c6c593e8807c398490811f7b6aa7242a2c96b9954fad34d3b147ea3fcb7441

Contents?: true

Size: 962 Bytes

Versions: 57

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module ActionMailbox
  # The base class for all Action Mailbox ingress controllers.
  class BaseController < ActionController::Base
    skip_forgery_protection

    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

Version data entries

57 entries across 56 versions & 6 rubygems

Version Path
actionmailbox-8.0.0 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.2.2 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.1.5 app/controllers/action_mailbox/base_controller.rb
actionmailbox-8.0.0.rc2 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.2.1.2 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.1.4.2 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.0.8.6 app/controllers/action_mailbox/base_controller.rb
actionmailbox-8.0.0.rc1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.2.1.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.1.4.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.0.8.5 app/controllers/action_mailbox/base_controller.rb
actionmailbox-8.0.0.beta1 app/controllers/action_mailbox/base_controller.rb
omg-actionmailbox-8.0.0.alpha9 app/controllers/action_mailbox/base_controller.rb
omg-actionmailbox-8.0.0.alpha8 app/controllers/action_mailbox/base_controller.rb
omg-actionmailbox-8.0.0.alpha7 app/controllers/action_mailbox/base_controller.rb
omg-actionmailbox-8.0.0.alpha4 app/controllers/action_mailbox/base_controller.rb
omg-actionmailbox-8.0.0.alpha3 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.1.4 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.2.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-7.2.0 app/controllers/action_mailbox/base_controller.rb