lib/faye/authentication.rb in faye-authentication-0.3.0 vs lib/faye/authentication.rb in faye-authentication-0.4.0
- old
+ new
@@ -29,7 +29,17 @@
payload = self.decode(signature, secret)
raise PayloadError if channel.to_s.empty? || clientId.to_s.empty?
raise PayloadError unless channel == payload['channel'] && clientId == payload['clientId']
true
end
+
+ def self.authentication_required?(message)
+ subscription_or_channel = message['subscription'] || message['channel']
+ !public_channel?(subscription_or_channel) && (message['channel'] == '/meta/subscribe' || (!(message['channel'].start_with?('/meta/'))))
+ end
+
+ def self.public_channel?(channel)
+ channel.start_with?('/public/') and not channel.include?('*')
+ end
+
end
end