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-Tenant-Token'

Instance Method Summary collapse

Constructor Details

#initialize(app, token) ⇒ TenantAuthentication

Returns a new instance of TenantAuthentication.



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

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

Instance Method Details

#call(env) ⇒ Object



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

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