Sha256: f48432f87a3c60bd84123ab38051ff4367af02029e7cf49043c7614a4000d365

Contents?: true

Size: 532 Bytes

Versions: 6

Compression:

Stored size: 532 Bytes

Contents

# frozen_string_literal: true
module FinAppsCore
  module Middleware
    # Adds a custom header for tenant level authorization.
    # If the value for this header already exists, it is not overriden.
    class TenantAuthentication < Faraday::Middleware
      KEY = 'X-FinApps-Token' unless defined? KEY

      def initialize(app, token)
        super(app)
        @header_value = token.to_s.strip
      end

      def call(env)
        env[:request_headers][KEY] ||= @header_value
        @app.call(env)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
finapps_core-2.0.11 lib/finapps_core/middleware/request/tenant_authentication.rb
finapps_core-2.0.10 lib/finapps_core/middleware/request/tenant_authentication.rb
finapps_core-2.0.9 lib/finapps_core/middleware/request/tenant_authentication.rb
finapps_core-2.0.8 lib/finapps_core/middleware/request/tenant_authentication.rb
finapps_core-2.0.7 lib/finapps_core/middleware/request/tenant_authentication.rb
finapps_core-2.0.6 lib/finapps_core/middleware/request/tenant_authentication.rb