Class: FinAppsCore::Middleware::TenantAuthentication
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FinAppsCore::Middleware::TenantAuthentication
- 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
- #call(env) ⇒ Object
-
#initialize(app, token) ⇒ TenantAuthentication
constructor
A new instance of TenantAuthentication.
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 |