Class: FinAppsCore::Middleware::TenantAuthentication

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/finapps_core/middleware/request/tenant_authentication.rb

Overview

Adds a custom header for tenant level authorization. If the value for this header already exists, it is not overriden.

Constant Summary collapse

KEY =
'X-FinApps-Token'

Instance Method Summary collapse

Constructor Details

#initialize(app, identifier, token) ⇒ TenantAuthentication

Returns a new instance of TenantAuthentication.



9
10
11
12
# File 'lib/finapps_core/middleware/request/tenant_authentication.rb', line 9

def initialize(app, identifier, token)
  super(app)
  @header_value = "#{identifier.to_s.strip}=#{token.to_s.strip}"
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
# File 'lib/finapps_core/middleware/request/tenant_authentication.rb', line 14

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