Class: Gorilla::Middleware::SignatureAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Gorilla::Middleware::SignatureAuth
- Defined in:
- lib/gorilla/middleware/signature_auth.rb
Constant Summary collapse
- SIGNATURE_METHOD =
'Signature'.freeze
- SIGNATURE_ALGO =
'HS256'.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ SignatureAuth
constructor
A new instance of SignatureAuth.
Constructor Details
#initialize(app, opts = {}) ⇒ SignatureAuth
Returns a new instance of SignatureAuth.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gorilla/middleware/signature_auth.rb', line 8 def initialize(app, opts={}) [:key, :secret].each do |key| raise ArgumentError, "#{key.inspect} is required" if !opts[key] end opts[:token_duration] ||= 5 * 60 super(app) @opts = opts end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 |
# File 'lib/gorilla/middleware/signature_auth.rb', line 19 def call(env) env[:request_headers]['Authorization'] = build_auth_header(env) @app.call(env) end |