carrierwave_securefile 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +7 -61
- data/VERSION +1 -1
- data/carrierwave_securefile.gemspec +1 -1
- data/lib/carrierwave_securefile.rb +0 -11
- metadata +14 -14
data/README.md
CHANGED
@@ -14,74 +14,20 @@ it should work fine just the same.
|
|
14
14
|
Ruby 1.9.3 w/ Rails 3.1.3. Realistically, it should work on Ruby 1.9.x and Rails 3.1.x, but may work on other configurations.
|
15
15
|
It hasn't been tested.
|
16
16
|
|
17
|
-
## Installation
|
17
|
+
## Installation and Usage
|
18
18
|
|
19
|
-
|
19
|
+
[Please refer to the Wiki For Installation and Usage.](https://github.com/dougc84/carrierwave_securefile/wiki/Usage)
|
20
20
|
|
21
|
-
|
22
|
-
gem 'carrierwave_securefile'
|
23
|
-
```
|
21
|
+
## Changes in 0.2.0
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
bundle
|
29
|
-
```
|
30
|
-
|
31
|
-
command to install.
|
32
|
-
|
33
|
-
## Usage
|
34
|
-
### Initializer
|
35
|
-
|
36
|
-
Add an initializer in yourapp/config/initializers. Name it *carrierwave_securefile.rb*. Add the following:
|
37
|
-
|
38
|
-
``` ruby
|
39
|
-
CarrierWave::SecureFile.configure do |config|
|
40
|
-
config.cypher = ("Your cypher code here")[0..55]
|
41
|
-
end
|
42
|
-
```
|
43
|
-
|
44
|
-
The cypher must be no longer than 56 characters.
|
45
|
-
|
46
|
-
### Uploader
|
47
|
-
|
48
|
-
``` ruby
|
49
|
-
process :secure_file
|
50
|
-
def secure_file
|
51
|
-
CarrierWave::SecureFile::Uploader.secure_file( model, self.to_s )
|
52
|
-
end
|
53
|
-
```
|
54
|
-
|
55
|
-
This sends the model data (typically nil, but differentiates between uploads and downloads) as well as the current file name
|
56
|
-
(self.to_s - which is needed to encrypt the file).
|
57
|
-
|
58
|
-
### Downloader
|
59
|
-
|
60
|
-
You will not be able to call YourUploader.asset_file (or whatever you chose with your CarrierWave uploader) directly. Create
|
61
|
-
a new get controller action, and use the following code. Change where appropriate. Assumed using an uploader named
|
62
|
-
UserFileUploader, and a model called UserFile.
|
63
|
-
|
64
|
-
``` ruby
|
65
|
-
def file
|
66
|
-
# get the decrypted file from the server. needs the uploader model and the record the file is attached to in your ORM.
|
67
|
-
decrypted_file = CarrierWave::SecureFile::Downloader.call( UserFileUploader, UserFile.find(params[:id]) )
|
68
|
-
# decrypted file is a hash set up as follows:
|
69
|
-
# decrypted_file[:file] - the decrypted file, hopefully saved in a tmp path, not somewhere public facing.
|
70
|
-
# decrypted_file[:content_type] - returns content type, if available.
|
71
|
-
# send the file to the user:
|
72
|
-
send_file decrypted_file[:file], :content_type => decrypted_file[:content_type]
|
73
|
-
# then immediately destroy the file. You don't want an unencrypted file saved on your server... or do you?
|
74
|
-
File.unlink decrypted_file[:file]
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
And that's it! You're good to go.
|
23
|
+
* Changed syntax for Downloader so, you know, it actually works. Would expect a "user_file" field before, now you specify
|
24
|
+
the file field.
|
25
|
+
* Added choice for encryption algorithm - Blowfish (default), Rijndael, GOST.
|
79
26
|
|
80
27
|
# To Do
|
81
28
|
|
82
|
-
* Add other encryption algorithms
|
83
29
|
* Integrate with 'process' method in uploader to make 4 lines of code into 1
|
84
|
-
* Refactoring and testing
|
30
|
+
* Refactoring and additional testing
|
85
31
|
|
86
32
|
# Contributing to carrierwave_securefile
|
87
33
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -5,8 +5,6 @@ require 'carrierwave/securefile/uploader.rb'
|
|
5
5
|
require 'carrierwave/securefile/downloader.rb'
|
6
6
|
require 'carrierwave/securefile/configuration.rb'
|
7
7
|
|
8
|
-
if defined? Crypt
|
9
|
-
|
10
8
|
begin # require blowfish
|
11
9
|
require 'crypt/blowfish'
|
12
10
|
rescue LoadError
|
@@ -28,14 +26,5 @@ if defined? Crypt
|
|
28
26
|
puts " You may need to add the crypt19 gem."
|
29
27
|
end
|
30
28
|
|
31
|
-
# begin # require idea
|
32
|
-
# require 'crypt/idea'
|
33
|
-
# rescue LoadError
|
34
|
-
# puts "WARNING: Failed to require crypt/idea, encryption may fail!"
|
35
|
-
# puts " You may need to add the crypt19 gem."
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
end
|
39
|
-
|
40
29
|
module CarrierWave
|
41
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_securefile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
16
|
-
requirement: &
|
16
|
+
requirement: &70118597533180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.5.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70118597533180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: crypt19
|
27
|
-
requirement: &
|
27
|
+
requirement: &70118597532600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70118597532600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda
|
38
|
-
requirement: &
|
38
|
+
requirement: &70118597532040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70118597532040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70118597531500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70118597531500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70118597547300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70118597547300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &70118597546640 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70118597546640
|
80
80
|
description: Secure, encrypted file uploads using Crypt19 and CarrierWave
|
81
81
|
email: doug@dougclarkonline.com
|
82
82
|
executables: []
|
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
segments:
|
120
120
|
- 0
|
121
|
-
hash:
|
121
|
+
hash: 890500087202366050
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
none: false
|
124
124
|
requirements:
|