Sha256: 2d99a10f6e9f390b5c96c24e6e53918761a7c321f790a0dcc67b63a88c3933b2

Contents?: true

Size: 994 Bytes

Versions: 87

Compression:

Stored size: 994 Bytes

Contents

# 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

Version data entries

87 entries across 85 versions & 7 rubygems

Version Path
actionmailbox-6.1.7.10 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.9 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.8 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.7 app/controllers/action_mailbox/base_controller.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionmailbox-6.1.6.1/app/controllers/action_mailbox/base_controller.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionmailbox-7.0.2.3/app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.6 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.5 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.4 app/controllers/action_mailbox/base_controller.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionmailbox-6.1.6.1/app/controllers/action_mailbox/base_controller.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionmailbox-7.0.2.3/app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.3 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.2 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.0.6.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.7 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.0.6 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.1.6.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.0.5.1 app/controllers/action_mailbox/base_controller.rb
actionmailbox-6.0.5 app/controllers/action_mailbox/base_controller.rb