Class: Zaikio::Directory::BasicAuthMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Zaikio::Directory::BasicAuthMiddleware
- Defined in:
- lib/zaikio/directory/basic_auth_middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.credentials ⇒ Object
9 10 11 12 |
# File 'lib/zaikio/directory/basic_auth_middleware.rb', line 9 def self.credentials @credentials ||= Concurrent::ThreadLocalVar.new { nil } @credentials.value end |
.credentials=(value) ⇒ Object
14 15 16 17 |
# File 'lib/zaikio/directory/basic_auth_middleware.rb', line 14 def self.credentials=(value) @credentials ||= Concurrent::ThreadLocalVar.new { nil } @credentials.value = value end |
.reset_credentials ⇒ Object
19 20 21 |
# File 'lib/zaikio/directory/basic_auth_middleware.rb', line 19 def self.reset_credentials self.credentials = nil end |
Instance Method Details
#call(request_env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/zaikio/directory/basic_auth_middleware.rb', line 23 def call(request_env) if self.class.credentials value = Base64.encode64(self.class.credentials.join(":")) value.delete!("\n") request_env[:request_headers]["Authorization"] = "Basic #{value}" end @app.call(request_env).on_complete do |response_env| end end |