Class: FacebookSigValidator
- Inherits:
-
Object
- Object
- FacebookSigValidator
- Defined in:
- lib/facebook_sig_validator.rb
Class Method Summary collapse
-
.valid_cookie?(cookies, app_id, secret) ⇒ Boolean
If the cookie is valid, return true.
Class Method Details
.valid_cookie?(cookies, app_id, secret) ⇒ Boolean
If the cookie is valid, return true. If the cookie is out of date or invalid, return false. cookies is a hash app_id is your facebook app id secret is your facebook app secret
8 9 10 11 12 13 |
# File 'lib/facebook_sig_validator.rb', line 8 def self.(, app_id, secret) = ["fbs_#{app_id}"].gsub(/\"/, "") rescue '' pairs = Hash[.split("&").map {|kv| kv.split("=") }] str = pairs.keys.sort.collect {|a| a == "sig" ? nil : "#{a}=#{pairs[a]}"}.reject {|a| a.nil?}.join("") (Digest::MD5.hexdigest(str + secret) == pairs["sig"]) && (pairs["expires"] == "0" || Time.now.to_i < pairs["expires"].to_i) end |