Sha256: d29f792b76f2c416502f7ee107e26f1f223249480a749d407fde167ac410f17a
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'uri' require 'digest' require 'base64' require_relative 'provider' module UrlTokenizer class Wowza < Provider def call(input_url, **options) options = global_options.merge options uri = URI.parse input_url folder_path = get_path uri return if folder_path.empty? || folder_path == '/' uri.query = encode_query folder_path, build_options(options) uri.to_s end private def get_path(uri) File.dirname(uri.path)[1..-1] # remove leading / or . end def digest(url) sha256 = Digest::SHA256.digest url Base64.urlsafe_encode64(sha256) end def build_options(token_options) server_params = { wowzatokenendtime: expiration_date(token_options[:expires_in]) }.delete_if { |k, v| v.nil? } server_params end def encode_query(url, provider_options) string_to_tokenize = [ "#{ url }?#{ key }", build_query(provider_options) ].compact.join '&' build_query provider_options.merge( wowzatokenhash: digest(string_to_tokenize) ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
url_tokenizer-1.1.3 | lib/url_tokenizer/wowza.rb |