url_tokenizer 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/url_tokenizer/cloudflare.rb +43 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c3d341b0eb57e0628e5c5aaba722cd3bd1114ce
|
4
|
+
data.tar.gz: a4eb5be460fac910bfdd06635ac17cd747d25e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f23f7f04209512f1384c36d053c580f0cedd1f77b2c6f058b63b74ecddf84cabadefa0bde9eaa9d8bf7158f60696bed006f99f3c963c3c7d098587de24aa3b8
|
7
|
+
data.tar.gz: c27fd0067035e4c0271d42d2d833357ce710228bdc2f5c2ddc3da2f8d72d7166ba3e90900a455e204a7d79e309fd83347c3e450b51bde8eccd759ee269959fa2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.6.0
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'uri'
|
3
|
+
require 'openssl'
|
4
|
+
require_relative 'provider'
|
5
|
+
|
6
|
+
module UrlTokenizer
|
7
|
+
class Cloudflare < Provider
|
8
|
+
def call(input_url, **options)
|
9
|
+
options = global_options.merge options
|
10
|
+
uri = URI.parse input_url
|
11
|
+
path = uri.path
|
12
|
+
return if path.empty? || path == '/'
|
13
|
+
|
14
|
+
expiration = expiration_date(options[:expires_in])
|
15
|
+
|
16
|
+
token = digest [string_to_tokenize(uri), expiration].compact.join
|
17
|
+
token = [expiration, token].compact.join '_'
|
18
|
+
|
19
|
+
params = parse_query_string(uri).merge(verify: token)
|
20
|
+
|
21
|
+
uri.query = build_query params
|
22
|
+
uri.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def string_to_tokenize(uri)
|
26
|
+
File.dirname(uri.path)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def parse_query_string(uri)
|
32
|
+
return {} if uri.query.nil?
|
33
|
+
|
34
|
+
Rack::Utils.parse_query(uri.query).tap do |params|
|
35
|
+
params.delete('verify')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def digest(string_to_sign)
|
40
|
+
OpenSSL::HMAC.hexdigest('sha1', key, string_to_sign)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Paramonov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facets
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- bin/setup
|
143
143
|
- lib/url_tokenizer.rb
|
144
144
|
- lib/url_tokenizer/cdn77.rb
|
145
|
+
- lib/url_tokenizer/cloudflare.rb
|
145
146
|
- lib/url_tokenizer/echo.rb
|
146
147
|
- lib/url_tokenizer/fastly.rb
|
147
148
|
- lib/url_tokenizer/fastly_query_string.rb
|
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
172
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.5.2.3
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: Tokenize url by variety of providers.
|