attache 2.3.0 → 3.0.0

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: d3e6fceada01d556d51cb23682428710b64a6a4f
4
- data.tar.gz: f1a1dd488a9964aaa212522fa6552776f31882af
3
+ metadata.gz: 2cde7af6587a7bd0d889116e932393567b21c67d
4
+ data.tar.gz: 89c025fc3fafb2a490aff53ae8e9596a63290a56
5
5
  SHA512:
6
- metadata.gz: b71efe1bd2bb1820c32f93bd60ab6bd7ce418e804cd6738ac51d77cb78ffc9eb7e2a9d2c79ce12cb258df463033a29e9f78e253fcb7732eb20758b22e912a16d
7
- data.tar.gz: b355c9cbe459befac3da3a8ec7d35f2ef2d5f10fbc3ae0c27639e2145fb4ad6f4259379ea91b803f9fdeda545a0fcc7529e47c2c3b4bd2d9907663c95a23e85d
6
+ metadata.gz: d6c4356d1fae80dee32d9a2957722c7ee887d7047c4f4df7cc2e44f81cd6ef934815d091d724f5efaa23f10a158a4fb8b9841098902d51a9ae1e5bb658b3ce74
7
+ data.tar.gz: 0fbdd6abd508fe825ec796b2e7db6b00155a8d0d3108d8b0b7c8b9355e0801dabd3ec38c77dd02928764bdc68c340bb76a90b37e9d212fd26184dc6fa6970501
@@ -60,14 +60,19 @@ class Attache::Base
60
60
  File.join(*SecureRandom.hex.scan(/\w\w/), basename)
61
61
  end
62
62
 
63
- def json_of(relpath, cachekey)
63
+ def json_of(relpath, cachekey, vhost)
64
64
  filepath = path_of(cachekey)
65
- {
65
+ json = {
66
66
  path: relpath,
67
67
  content_type: content_type_of(filepath),
68
68
  geometry: geometry_of(filepath),
69
69
  bytes: filesize_of(filepath),
70
- }.to_json
70
+ }
71
+ if vhost && vhost.secret_key
72
+ content = json.sort.collect {|k,v| "#{k}=#{v}" }.join('&')
73
+ json['signature'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), vhost.secret_key, content)
74
+ end
75
+ json.to_json
71
76
  end
72
77
 
73
78
  end
@@ -39,7 +39,7 @@ class Attache::Tus::Upload < Attache::Base
39
39
 
40
40
  [200,
41
41
  tus.headers_with_cors({'Content-Type' => 'text/json'}, offset: current_offset(cachekey, relpath, config)),
42
- [json_of(relpath, cachekey)],
42
+ [json_of(relpath, cachekey, config)],
43
43
  ]
44
44
  else
45
45
  [400, tus.headers_with_cors('X-Exception' => 'Bad headers'), []]
@@ -53,7 +53,7 @@ class Attache::Tus::Upload < Attache::Base
53
53
  cachekey = File.join(request_hostname(env), relpath)
54
54
  [200,
55
55
  tus.headers_with_cors({'Content-Type' => 'text/json'}, offset: current_offset(cachekey, relpath, config)),
56
- [json_of(relpath, cachekey)],
56
+ [json_of(relpath, cachekey, config)],
57
57
  ]
58
58
 
59
59
  when 'GET'
@@ -24,7 +24,7 @@ class Attache::Upload < Attache::Base
24
24
 
25
25
  config.storage_create(relpath: relpath, cachekey: cachekey) if config.storage && config.bucket
26
26
 
27
- [200, config.headers_with_cors.merge('Content-Type' => 'text/json'), [json_of(relpath, cachekey)]]
27
+ [200, config.headers_with_cors.merge('Content-Type' => 'text/json'), [json_of(relpath, cachekey, config)]]
28
28
  when 'OPTIONS'
29
29
  [200, config.headers_with_cors, []]
30
30
  else
@@ -1,3 +1,3 @@
1
1
  module Attache
2
- VERSION = "2.3.0"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - choonkeat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-24 00:00:00.000000000 Z
11
+ date: 2016-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack