Module: Pusher::Utils
Instance Method Summary collapse
-
#_authentication_string(socket_id, string_to_sign, token, custom_string = nil) ⇒ String
Compute authentication string required as part of the user authentication and subscription authorization endpoints responses.
- #validate_socket_id(socket_id) ⇒ Object
Instance Method Details
#_authentication_string(socket_id, string_to_sign, token, custom_string = nil) ⇒ String
Compute authentication string required as part of the user authentication and subscription authorization endpoints responses. Generally the authenticate method should be used in preference to this one.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pusher/utils.rb', line 21 def _authentication_string(socket_id, string_to_sign, token, custom_string = nil) validate_socket_id(socket_id) raise Pusher::Error, 'Custom argument must be a string' unless custom_string.nil? || custom_string.is_a?(String) Pusher.logger.debug "Signing #{string_to_sign}" digest = OpenSSL::Digest.new('SHA256') signature = OpenSSL::HMAC.hexdigest(digest, token.secret, string_to_sign) "#{token.key}:#{signature}" end |