Module: Sockudo::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.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sockudo/utils.rb', line 23 def _authentication_string(socket_id, string_to_sign, token, custom_string = nil) validate_socket_id(socket_id) raise Sockudo::Error, 'Custom argument must be a string' unless custom_string.nil? || custom_string.is_a?(String) Sockudo.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 |