Sha256: 3c99431c51004e78ea2c17037fa80232ca93615a00b82f101e22aece031a2ee1

Contents?: true

Size: 570 Bytes

Versions: 24

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true
module FinApps
  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, identifier, token)
        super(app)
        @header_value = "#{identifier.to_s.strip}=#{token.to_s.strip}"
      end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
finapps-2.1.4 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.1.3 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.1.2 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.1.1 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.30 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.29 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.28 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.27 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.26 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.25 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.24 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.23 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.22 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.21 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.20 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.19 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.17 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.16 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.15 lib/finapps/middleware/request/tenant_authentication.rb
finapps-2.0.14 lib/finapps/middleware/request/tenant_authentication.rb