Class: EY::GateKeeper::Client::Middleware::ServiceTokenAuthentication
- Inherits:
-
Object
- Object
- EY::GateKeeper::Client::Middleware::ServiceTokenAuthentication
- Defined in:
- lib/ey_gatekeeper/client/middlewares/service_token_authentication.rb
Overview
This middleware is for use by service clients.
Given the service client’s app to run along with a gatekeeper endpoint, key, and secret it will contact the gatekeeper and retrieve a token. The token will then be passed as part of the request in the ‘Auth-Token` header.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #current_token ⇒ Object
- #gatekeeper_client ⇒ Object
-
#initialize(app, gatekeeper_endpoint, xdna_key, xdna_secret) ⇒ ServiceTokenAuthentication
constructor
A new instance of ServiceTokenAuthentication.
Constructor Details
#initialize(app, gatekeeper_endpoint, xdna_key, xdna_secret) ⇒ ServiceTokenAuthentication
Returns a new instance of ServiceTokenAuthentication.
17 18 19 20 |
# File 'lib/ey_gatekeeper/client/middlewares/service_token_authentication.rb', line 17 def initialize(app, gatekeeper_endpoint, xdna_key, xdna_secret) @app, @gatekeeper_endpoint, @xdna_key, @xdna_secret = app, gatekeeper_endpoint, xdna_key, xdna_secret end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 |
# File 'lib/ey_gatekeeper/client/middlewares/service_token_authentication.rb', line 22 def call(env) env.merge!('HTTP_AUTH_TOKEN' => current_token.token) @app.call(env) end |
#current_token ⇒ Object
31 32 33 |
# File 'lib/ey_gatekeeper/client/middlewares/service_token_authentication.rb', line 31 def current_token gatekeeper_client.token end |
#gatekeeper_client ⇒ Object
27 28 29 |
# File 'lib/ey_gatekeeper/client/middlewares/service_token_authentication.rb', line 27 def gatekeeper_client @gatekeeper_client ||= EY::GateKeeper.new(@xdna_key, @xdna_secret, :endpoint => @gatekeeper_endpoint) end |