class Fyb::Middleware::Authorize
Adds the key and secret signature to the weary request
Public Class Methods
new(app)
click to toggle source
# File lib/fyb/middleware/authorize.rb, line 7 def initialize(app) @app = app @key = Fyb::Configuration.key @sig = Fyb::Configuration.sig end
Public Instance Methods
call(env)
click to toggle source
# File lib/fyb/middleware/authorize.rb, line 14 def call(env) env.update 'HTTP_SIG' => generate_signature(env), 'HTTP_KEY' => @key @app.call(env) end
generate_signature(env)
click to toggle source
# File lib/fyb/middleware/authorize.rb, line 20 def generate_signature(env) body = env['weary.request'].body.string hmac = HMAC::SHA1.new(@sig) hmac.update(body) hmac.hexdigest end