Class: FabricCA::FaradayMiddleware::TokenAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FabricCA::FaradayMiddleware::TokenAuth
- Defined in:
- lib/fabric_ca/faraday_middleware/token_auth.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, identity) ⇒ TokenAuth
constructor
A new instance of TokenAuth.
Constructor Details
#initialize(app, identity) ⇒ TokenAuth
Returns a new instance of TokenAuth.
20 21 22 23 |
# File 'lib/fabric_ca/faraday_middleware/token_auth.rb', line 20 def initialize(app, identity) @app = app @identity = identity end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/fabric_ca/faraday_middleware/token_auth.rb', line 7 def app @app end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
7 8 9 |
# File 'lib/fabric_ca/faraday_middleware/token_auth.rb', line 7 def identity @identity end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fabric_ca/faraday_middleware/token_auth.rb', line 9 def call(env) if identity env[:request_headers] = env[:request_headers].merge( 'Authorization' => generate_auth_header(env) ) end app.call env end |