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