Class: ConnectorsShared::Middleware::BearerAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/connectors_shared/middleware/bearer_auth.rb

Constant Summary collapse

AUTHORIZATION =
'Authorization'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, options = {}) ⇒ BearerAuth

Returns a new instance of BearerAuth.



16
17
18
19
# File 'lib/connectors_shared/middleware/bearer_auth.rb', line 16

def initialize(app = nil, options = {})
  @app = app
  @bearer_auth_token = options.fetch(:bearer_auth_token)
end

Instance Attribute Details

#bearer_auth_tokenObject (readonly)

Returns the value of attribute bearer_auth_token.



14
15
16
# File 'lib/connectors_shared/middleware/bearer_auth.rb', line 14

def bearer_auth_token
  @bearer_auth_token
end

Instance Method Details

#call(env) ⇒ Object



21
22
23
24
# File 'lib/connectors_shared/middleware/bearer_auth.rb', line 21

def call(env)
  env.request_headers[AUTHORIZATION] = "Bearer #{bearer_auth_token}"
  @app.call(env)
end