Sha256: 5db9f1eb9f053c08265d34d3c787f5d714e9116d5783bba129bd72e8cb961874

Contents?: true

Size: 1.02 KB

Versions: 21

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module NeetoCommonsBackend
  module SecretsManagement
    def neeto_secrets
      @_neeto_secrets ||= begin
        secrets = ActiveSupport::OrderedOptions.new
        secrets.deep_merge! common_secrets
        secrets.deep_merge! host_app_secrets

        # Fallback to config.secret_key_base if secrets.secret_key_base isn't set
        secrets.secret_key_base ||= config.secret_key_base

        secrets
      end

      @secrets = @_neeto_secrets
    end

    private

      def host_app_secrets
        files = config.paths["config/secrets"].existent
        files = files.reject { |path| path.end_with?(".enc") } unless config.read_encrypted_secrets
        _read_secrets files
      end

      def common_secrets
        _read_secrets [File.join(__dir__, "config/secrets.yml")]
      end

      def _read_secrets(files)
        Rails::Secrets.parse(files, env: Rails.env)
      end
  end
end

class Rails::Application
  include NeetoCommonsBackend::SecretsManagement
  alias_method :secrets, :neeto_secrets
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.108 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.107 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.106 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.105 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.104 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.103 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.102 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.101 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.100 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.99 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.98 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.97 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.96 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.95 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.94 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.93 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.92 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.91 lib/neeto_commons_backend/secrets_management.rb
neeto-commons-backend-1.0.90 lib/neeto_commons_backend/secrets_management.rb