url_tokenizer 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8774aa493e82940b14acf5698bbd55738ec1306
4
- data.tar.gz: 2edfdfbd8202188ee1b156879883cc1c758982f8
3
+ metadata.gz: 0986700f3d09a93ee40fa87e98b22bef740d65ee
4
+ data.tar.gz: 1d2d36c5d9dd5c8e64513acc3424e1582e8956cd
5
5
  SHA512:
6
- metadata.gz: 4373ed4dfe200431de2f311d0ae1a2cd4cac13cc880cefa522e7e6ab44ee0962049a2f4ee927d761f796c1e90f743a59ed90bfa78a5fb68beabf4d4f31990118
7
- data.tar.gz: 737aed77087313af778b1874c3eeabb015a21fa6a446bc83d8a513b282496caad90c704a0cb0461009e85a058594a690692dbd8755cb76b269e0b44b7dea1349
6
+ metadata.gz: c389214dec19186c62700876375ca0ba36edcb86fa1b2c92d8c98fd98a2d324ca91f3672833f5da2caa400bc31b7f5a8fef4a02577fca5e57857303a4bd7e2b8
7
+ data.tar.gz: d8d076a87f1fa00c205e39bcc3df0980172185c65c82f51c8a56086ceddd93a8a88083c8ba1e5ead5190e815770c7d4fac17a2f0cae97a8c73b835eea047d3f8
data/.env.sample CHANGED
@@ -1,2 +1,3 @@
1
1
  LL_TOKEN=secret
2
2
  CDN77_TOKEN=secret
3
+ WOWZA_TOKEN=secret
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -20,19 +20,9 @@ module UrlTokenizer
20
20
  end
21
21
 
22
22
  private
23
- def expiration_date(expires_in)
24
- Time.now.utc.to_i + expires_in.to_i if expires_in
25
- end
26
-
27
23
  def digest(url)
28
24
  md5 = Digest::MD5.digest url
29
25
  Base64.urlsafe_encode64(md5)
30
26
  end
31
-
32
- def build_query(provider_options)
33
- provider_options.reduce([]) do |query, (key, value)|
34
- query << "#{ key }=#{ value }"
35
- end.join '&'
36
- end
37
27
  end
38
28
  end
@@ -58,10 +58,6 @@ module UrlTokenizer
58
58
  end
59
59
  end
60
60
 
61
- def expiration_date(expires_in)
62
- Time.now.utc.to_i + expires_in.to_i if expires_in
63
- end
64
-
65
61
  def digest(url)
66
62
  Digest::MD5.hexdigest "#{ key }#{ url }"
67
63
  end
@@ -11,5 +11,15 @@ module UrlTokenizer
11
11
 
12
12
  private
13
13
  attr_reader :key, :global_options
14
+
15
+ def build_query(provider_options)
16
+ provider_options.reduce([]) do |query, (key, value)|
17
+ query << "#{ key }=#{ value }"
18
+ end.join '&'
19
+ end
20
+
21
+ def expiration_date(expires_in)
22
+ Time.now.utc.to_i + expires_in.to_i if expires_in
23
+ end
14
24
  end
15
25
  end
@@ -0,0 +1,48 @@
1
+ require 'uri'
2
+ require 'digest'
3
+ require 'base64'
4
+ require_relative 'provider'
5
+
6
+ module UrlTokenizer
7
+ class Wowza < Provider
8
+ def call(input_url, **options)
9
+ options = global_options.merge options
10
+ uri = URI.parse input_url
11
+
12
+ folder_path = get_path uri
13
+ return if folder_path.empty? || folder_path == '/'
14
+
15
+ uri.query = encode_query folder_path, build_options(options)
16
+ uri.to_s
17
+ end
18
+
19
+ private
20
+ def get_path(uri)
21
+ File.dirname(uri.path)[1..-1] # remove leading / or .
22
+ end
23
+
24
+ def digest(url)
25
+ sha256 = Digest::SHA256.digest url
26
+ Base64.urlsafe_encode64(sha256)
27
+ end
28
+
29
+ def build_options(token_options)
30
+ server_params = {
31
+ wowzatokenendtime: expiration_date(token_options[:expires_in])
32
+ }.delete_if { |k, v| v.nil? }
33
+
34
+ server_params
35
+ end
36
+
37
+ def encode_query(url, provider_options)
38
+ string_to_tokenize = [
39
+ "#{ url }?#{ key }",
40
+ build_query(provider_options)
41
+ ].compact.join '&'
42
+
43
+ build_query provider_options.merge(
44
+ wowzatokenhash: digest(string_to_tokenize)
45
+ )
46
+ end
47
+ end
48
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_tokenizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Paramonov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -116,6 +116,7 @@ files:
116
116
  - lib/url_tokenizer/cdn77.rb
117
117
  - lib/url_tokenizer/limelight.rb
118
118
  - lib/url_tokenizer/provider.rb
119
+ - lib/url_tokenizer/wowza.rb
119
120
  - url_tokenizer.gemspec
120
121
  homepage: http://github.com/AlexParamonov/url_tokenizer
121
122
  licenses: