Class: WP::HMAC::Server
- Inherits:
-
Object
- Object
- WP::HMAC::Server
- Defined in:
- lib/wp/hmac/server.rb
Overview
HMAC Server
Authenticate a request using EY::ApiHMAC
Class Attribute Summary collapse
-
.hmac_enabled_routes ⇒ Object
Returns the value of attribute hmac_enabled_routes.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #id_for_request ⇒ Object
-
#initialize(app) ⇒ Server
constructor
A new instance of Server.
- #verify_key! ⇒ Object
Constructor Details
#initialize(app) ⇒ Server
Returns a new instance of Server.
13 14 15 16 |
# File 'lib/wp/hmac/server.rb', line 13 def initialize(app) @app = app @hmac_auth = EY::ApiHMAC::ApiAuth::Server.new(app, HMAC::KeyCabinet) end |
Class Attribute Details
.hmac_enabled_routes ⇒ Object
Returns the value of attribute hmac_enabled_routes.
10 11 12 |
# File 'lib/wp/hmac/server.rb', line 10 def hmac_enabled_routes @hmac_enabled_routes end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/wp/hmac/server.rb', line 18 def call(env) if hmac_enabled_route?(env) verify_key! @hmac_auth.call(env) else @app.call(env) end end |
#id_for_request ⇒ Object
31 32 33 |
# File 'lib/wp/hmac/server.rb', line 31 def id_for_request HMAC.auth_id end |
#verify_key! ⇒ Object
27 28 29 |
# File 'lib/wp/hmac/server.rb', line 27 def verify_key! KeyCabinet.find_by_auth_id(id_for_request) end |