Module: Sinatra::FacebookSignedRequest::Helpers

Defined in:
lib/sinatra/facebook_signed_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#facebook_paramsObject

Returns the value of attribute facebook_params.



15
16
17
# File 'lib/sinatra/facebook_signed_request.rb', line 15

def facebook_params
  @facebook_params
end

Instance Method Details

#ensure_signed_request!(secret) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sinatra/facebook_signed_request.rb', line 17

def ensure_signed_request!(secret)
  unless params[:signed_request]
    raise BadRequest, 'missing signature'
  end
  signed_request = params[:signed_request]
  signature, signed_params = signed_request.split('.')

  unless signed_request_is_valid?(secret, signature, signed_params)
    raise BadRequest, 'invalid signature'
  end
  @facebook_params = Yajl::Parser.new.parse(base64_url_decode(signed_params))
end