Class: FabricCA::FaradayMiddleware::TokenAuth

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/fabric_ca/faraday_middleware/token_auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#appObject (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

#identityObject (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