Sha256: 0188344a44eba79271ce86995b621d2a88fdd86b1bbf41633c3d3a29f68cbd0d
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
require 'faye' module Faye module Authentication class ServerExtension include Faye::Logging def initialize(secret, options = {}) @options = options @secret = secret.to_s end 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 end end end
Version data entries
4 entries across 4 versions & 1 rubygems