diff --git a/lib/private_pub/faye_extension.rb b/lib/private_pub/faye_extension.rb index 4a89fc5..7f3840e 100644 --- a/lib/private_pub/faye_extension.rb +++ b/lib/private_pub/faye_extension.rb @@ -18,7 +18,7 @@ def incoming(message, callback) # Ensure the subscription signature is correct and that it has not expired. def authenticate_subscribe(message) subscription = PrivatePub.subscription(:channel => message["subscription"], :timestamp => message["ext"]["private_pub_timestamp"]) - if message["ext"]["private_pub_signature"] != subscription[:signature] + if message["ext"].nil? || message["ext"]["private_pub_signature"] != subscription[:signature] message["error"] = "Incorrect signature." elsif PrivatePub.signature_expired? message["ext"]["private_pub_timestamp"].to_i message["error"] = "Signature has expired." @@ -29,7 +29,7 @@ def authenticate_subscribe(message) def authenticate_publish(message) if PrivatePub.config[:secret_token].nil? raise Error, "No secret_token config set, ensure private_pub.yml is loaded properly." - elsif message["ext"]["private_pub_token"] != PrivatePub.config[:secret_token] + elsif message["ext"].nil? || message["ext"]["private_pub_token"] != PrivatePub.config[:secret_token] message["error"] = "Incorrect token." else message["ext"]["private_pub_token"] = nil