apache_secure_download 0.0.2.213 → 0.0.3.217
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/README +7 -1
- data/lib/apache/secure_download/util.rb +11 -2
- data/lib/apache/secure_download/version.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= Revision history for apache_secure_download
|
2
2
|
|
3
|
+
== 0.0.3 [2008-02-25]
|
4
|
+
|
5
|
+
* Apache::SecureDownload::Util.secure_url
|
6
|
+
** also takes a hash with options instead of explicit expiration time
|
7
|
+
** can create cacheable URLs by setting the <tt>:cache</tt> option
|
8
|
+
|
3
9
|
== 0.0.2 [2008-02-20]
|
4
10
|
|
5
11
|
* Added helper module Apache::SecureDownload::Util
|
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to apache_secure_download version 0.0.
|
5
|
+
This documentation refers to apache_secure_download version 0.0.3
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
@@ -32,6 +32,12 @@ And create links to your resources with timestamp and token:
|
|
32
32
|
# or simply use the provided helper:
|
33
33
|
url = Apache::SecureDownload::Util.secure_url("secret", path, 1.minute.from_now)
|
34
34
|
|
35
|
+
# make resulting URL cacheable for 30 seconds (on average):
|
36
|
+
url = Apache::SecureDownload::Util.secure_url("secret", path, :expires => 1.minute.from_now, :cache => 30)
|
37
|
+
|
38
|
+
# specify expiration time using an offset (results in Time.now + 60; also includes caching for 60 seconds):
|
39
|
+
url = Apache::SecureDownload::Util.secure_url("secret", path, :offset => 60)
|
40
|
+
|
35
41
|
|
36
42
|
== AUTHORS
|
37
43
|
|
@@ -41,11 +41,20 @@ module Apache
|
|
41
41
|
Digest::SHA1.hexdigest(secret + path + timestamp.to_s)
|
42
42
|
end
|
43
43
|
|
44
|
-
def secure_url(secret, url,
|
44
|
+
def secure_url(secret, url, expires = Time.now + 60)
|
45
45
|
path, _, query = URI.split(url)[5..7]
|
46
46
|
path << '?' << query if query
|
47
47
|
|
48
|
-
|
48
|
+
if expires.is_a?(Hash)
|
49
|
+
timestamp = (expires[:expires] || Time.now + (expires[:offset] ||= 60)).to_i
|
50
|
+
|
51
|
+
unless expires[:cache] == false || (cache = expires[:cache] || expires[:offset]).zero?
|
52
|
+
# makes the URL cacheable for +cache+ seconds *on average*
|
53
|
+
timestamp = ((timestamp / cache.to_f).round + 1) * cache.to_i
|
54
|
+
end
|
55
|
+
else
|
56
|
+
timestamp = expires.to_i
|
57
|
+
end
|
49
58
|
|
50
59
|
url + "#{query ? '&' : '?'}timestamp=#{timestamp}&token=#{token(secret, path, timestamp)}"
|
51
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apache_secure_download
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.217
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|