class Faye::Authentication::ServerExtension
Public Class Methods
new(secret, options = {})
click to toggle source
# File lib/faye/authentication/server_extension.rb, line 8 def initialize(secret, options = {}) @options = options @secret = secret.to_s end
Public Instance Methods
incoming(message, callback)
click to toggle source
# File lib/faye/authentication/server_extension.rb, line 13 def incoming(message, callback) if Faye::Authentication.authentication_required?(message, @options) begin Faye::Authentication.validate(message['signature'], message['subscription'] || message['channel'], message['clientId'], @secret) debug("Authentication sucessful") rescue AuthError => exception message['error'] = case exception when ExpiredError then 'Expired signature' when PayloadError then 'Required argument not signed' else 'Invalid signature' end debug("Authentication failed: #{message['error']}") end message.delete('signature') end callback.call(message) end