activestorage-horcrux 0.0.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.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +171 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/activestorage-horcrux.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/active_storage/service/horcrux_service.rb +118 -0
- data/lib/active_storage/service/version.rb +5 -0
- metadata +143 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: dc8bb0a018830fa20e443f065cd756231cd2872d51d09ba0a0da43e48bfd2d08
|
|
4
|
+
data.tar.gz: f6f24bd9fea6fae6e8f80c23ca9775473792c4cfc9dc2e00edd2fce9c2f4b4e8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4ca6492807a097e183468d06700e77347978f6b4b1576acab4a102a8fa18e08c306cceba5d7e4d6c8096d7af1ead0b116bc4ebd7ec08858d2b502df0b938c6e5
|
|
7
|
+
data.tar.gz: 38f64bef48b480d925e4ac8e0dee3ca68a75c43e93d8f25aedddcf8a0b3d0a4ff404d1333a824dfd828bc6c62b0173f35f3d38cda0e49bb75b9407c4cb11cde8
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at mail@ashishprajapati.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
activestorage-horcrux (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actioncable (5.2.4.3)
|
|
10
|
+
actionpack (= 5.2.4.3)
|
|
11
|
+
nio4r (~> 2.0)
|
|
12
|
+
websocket-driver (>= 0.6.1)
|
|
13
|
+
actionmailer (5.2.4.3)
|
|
14
|
+
actionpack (= 5.2.4.3)
|
|
15
|
+
actionview (= 5.2.4.3)
|
|
16
|
+
activejob (= 5.2.4.3)
|
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
|
18
|
+
rails-dom-testing (~> 2.0)
|
|
19
|
+
actionpack (5.2.4.3)
|
|
20
|
+
actionview (= 5.2.4.3)
|
|
21
|
+
activesupport (= 5.2.4.3)
|
|
22
|
+
rack (~> 2.0, >= 2.0.8)
|
|
23
|
+
rack-test (>= 0.6.3)
|
|
24
|
+
rails-dom-testing (~> 2.0)
|
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
26
|
+
actionview (5.2.4.3)
|
|
27
|
+
activesupport (= 5.2.4.3)
|
|
28
|
+
builder (~> 3.1)
|
|
29
|
+
erubi (~> 1.4)
|
|
30
|
+
rails-dom-testing (~> 2.0)
|
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
32
|
+
activejob (5.2.4.3)
|
|
33
|
+
activesupport (= 5.2.4.3)
|
|
34
|
+
globalid (>= 0.3.6)
|
|
35
|
+
activemodel (5.2.4.3)
|
|
36
|
+
activesupport (= 5.2.4.3)
|
|
37
|
+
activerecord (5.2.4.3)
|
|
38
|
+
activemodel (= 5.2.4.3)
|
|
39
|
+
activesupport (= 5.2.4.3)
|
|
40
|
+
arel (>= 9.0)
|
|
41
|
+
activestorage (5.2.4.3)
|
|
42
|
+
actionpack (= 5.2.4.3)
|
|
43
|
+
activerecord (= 5.2.4.3)
|
|
44
|
+
marcel (~> 0.3.1)
|
|
45
|
+
activesupport (5.2.4.3)
|
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
47
|
+
i18n (>= 0.7, < 2)
|
|
48
|
+
minitest (~> 5.1)
|
|
49
|
+
tzinfo (~> 1.1)
|
|
50
|
+
arel (9.0.0)
|
|
51
|
+
binary_struct (2.1.0)
|
|
52
|
+
builder (3.2.4)
|
|
53
|
+
concurrent-ruby (1.1.6)
|
|
54
|
+
contracts (0.16.0)
|
|
55
|
+
coveralls (0.8.23)
|
|
56
|
+
json (>= 1.8, < 3)
|
|
57
|
+
simplecov (~> 0.16.1)
|
|
58
|
+
term-ansicolor (~> 1.3)
|
|
59
|
+
thor (>= 0.19.4, < 2.0)
|
|
60
|
+
tins (~> 1.6)
|
|
61
|
+
crass (1.0.6)
|
|
62
|
+
diff-lcs (1.4.4)
|
|
63
|
+
docile (1.3.2)
|
|
64
|
+
erubi (1.9.0)
|
|
65
|
+
globalid (0.4.2)
|
|
66
|
+
activesupport (>= 4.2.0)
|
|
67
|
+
i18n (1.8.5)
|
|
68
|
+
concurrent-ruby (~> 1.0)
|
|
69
|
+
json (2.3.1)
|
|
70
|
+
loofah (2.6.0)
|
|
71
|
+
crass (~> 1.0.2)
|
|
72
|
+
nokogiri (>= 1.5.9)
|
|
73
|
+
mail (2.7.1)
|
|
74
|
+
mini_mime (>= 0.1.1)
|
|
75
|
+
marcel (0.3.3)
|
|
76
|
+
mimemagic (~> 0.3.2)
|
|
77
|
+
method_source (1.0.0)
|
|
78
|
+
mimemagic (0.3.5)
|
|
79
|
+
mini_mime (1.0.2)
|
|
80
|
+
mini_portile2 (2.4.0)
|
|
81
|
+
minitest (5.14.1)
|
|
82
|
+
nio4r (2.5.2)
|
|
83
|
+
nokogiri (1.10.10)
|
|
84
|
+
mini_portile2 (~> 2.4.0)
|
|
85
|
+
rack (2.2.3)
|
|
86
|
+
rack-test (1.1.0)
|
|
87
|
+
rack (>= 1.0, < 3)
|
|
88
|
+
rails (5.2.4.3)
|
|
89
|
+
actioncable (= 5.2.4.3)
|
|
90
|
+
actionmailer (= 5.2.4.3)
|
|
91
|
+
actionpack (= 5.2.4.3)
|
|
92
|
+
actionview (= 5.2.4.3)
|
|
93
|
+
activejob (= 5.2.4.3)
|
|
94
|
+
activemodel (= 5.2.4.3)
|
|
95
|
+
activerecord (= 5.2.4.3)
|
|
96
|
+
activestorage (= 5.2.4.3)
|
|
97
|
+
activesupport (= 5.2.4.3)
|
|
98
|
+
bundler (>= 1.3.0)
|
|
99
|
+
railties (= 5.2.4.3)
|
|
100
|
+
sprockets-rails (>= 2.0.0)
|
|
101
|
+
rails-dom-testing (2.0.3)
|
|
102
|
+
activesupport (>= 4.2.0)
|
|
103
|
+
nokogiri (>= 1.6)
|
|
104
|
+
rails-html-sanitizer (1.3.0)
|
|
105
|
+
loofah (~> 2.3)
|
|
106
|
+
railties (5.2.4.3)
|
|
107
|
+
actionpack (= 5.2.4.3)
|
|
108
|
+
activesupport (= 5.2.4.3)
|
|
109
|
+
method_source
|
|
110
|
+
rake (>= 0.8.7)
|
|
111
|
+
thor (>= 0.19.0, < 2.0)
|
|
112
|
+
rake (10.5.0)
|
|
113
|
+
rspec (3.9.0)
|
|
114
|
+
rspec-core (~> 3.9.0)
|
|
115
|
+
rspec-expectations (~> 3.9.0)
|
|
116
|
+
rspec-mocks (~> 3.9.0)
|
|
117
|
+
rspec-core (3.9.2)
|
|
118
|
+
rspec-support (~> 3.9.3)
|
|
119
|
+
rspec-expectations (3.9.2)
|
|
120
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
121
|
+
rspec-support (~> 3.9.0)
|
|
122
|
+
rspec-mocks (3.9.1)
|
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
124
|
+
rspec-support (~> 3.9.0)
|
|
125
|
+
rspec-support (3.9.3)
|
|
126
|
+
simplecov (0.16.1)
|
|
127
|
+
docile (~> 1.1)
|
|
128
|
+
json (>= 1.8, < 3)
|
|
129
|
+
simplecov-html (~> 0.10.0)
|
|
130
|
+
simplecov-html (0.10.2)
|
|
131
|
+
sprockets (4.0.2)
|
|
132
|
+
concurrent-ruby (~> 1.0)
|
|
133
|
+
rack (> 1, < 3)
|
|
134
|
+
sprockets-rails (3.2.1)
|
|
135
|
+
actionpack (>= 4.0)
|
|
136
|
+
activesupport (>= 4.0)
|
|
137
|
+
sprockets (>= 3.0.0)
|
|
138
|
+
sync (0.5.0)
|
|
139
|
+
sysrandom (1.0.5)
|
|
140
|
+
term-ansicolor (1.7.1)
|
|
141
|
+
tins (~> 1.0)
|
|
142
|
+
thor (0.20.3)
|
|
143
|
+
thread_safe (0.3.6)
|
|
144
|
+
tins (1.25.0)
|
|
145
|
+
sync
|
|
146
|
+
tss (0.4.2)
|
|
147
|
+
activesupport (>= 4.0.0)
|
|
148
|
+
binary_struct (~> 2.1)
|
|
149
|
+
contracts (~> 0.14)
|
|
150
|
+
sysrandom (~> 1.0.3, >= 1.0.3)
|
|
151
|
+
thor (~> 0.19)
|
|
152
|
+
tzinfo (1.2.7)
|
|
153
|
+
thread_safe (~> 0.1)
|
|
154
|
+
websocket-driver (0.7.3)
|
|
155
|
+
websocket-extensions (>= 0.1.0)
|
|
156
|
+
websocket-extensions (0.1.5)
|
|
157
|
+
|
|
158
|
+
PLATFORMS
|
|
159
|
+
ruby
|
|
160
|
+
|
|
161
|
+
DEPENDENCIES
|
|
162
|
+
activestorage-horcrux!
|
|
163
|
+
bundler (~> 1.17.3)
|
|
164
|
+
coveralls (~> 0.8.22)
|
|
165
|
+
rails (~> 5.2)
|
|
166
|
+
rake (~> 10.0)
|
|
167
|
+
rspec (~> 3.0)
|
|
168
|
+
tss (~> 0.4.0)
|
|
169
|
+
|
|
170
|
+
BUNDLED WITH
|
|
171
|
+
1.17.3
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Ashish Prajapati
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[](https://travis-ci.org/johncallahan/activestorage-horcrux)
|
|
2
|
+
|
|
3
|
+
An ActiveStorage gem that uploads across one or more other
|
|
4
|
+
ActiveStorage services using Shamir Secret Sharing (via the [tss-rb
|
|
5
|
+
gem](https://github.com/grempe/tss-rb)). Use it in your storage.yml
|
|
6
|
+
file. It is not a mirror, but can be named as a storage service.
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
# in storage.yml
|
|
10
|
+
disk1:
|
|
11
|
+
service: Disk
|
|
12
|
+
root: "tmp/disk1"
|
|
13
|
+
|
|
14
|
+
disk2:
|
|
15
|
+
service: Disk
|
|
16
|
+
root: "tmp/disk2"
|
|
17
|
+
|
|
18
|
+
horcrux:
|
|
19
|
+
service: Horcrux
|
|
20
|
+
shares: 5
|
|
21
|
+
threshold: 3
|
|
22
|
+
services: [ disk1, disk2 ]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Configuration elements:
|
|
26
|
+
|
|
27
|
+
* service: name of the service
|
|
28
|
+
* shares: specified the number of shares split across services.
|
|
29
|
+
* threshold: specifies the _minimum_ number of shares are needed to
|
|
30
|
+
reconstruct the contents.
|
|
31
|
+
* services: one or more other ActiveStorage services in storage.yml
|
|
32
|
+
|
|
33
|
+
Instead of a single key, an array of keys is passed to the upload
|
|
34
|
+
function. The array of keys is not persisted and can be shown to the
|
|
35
|
+
user for subsequent downloads.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'active_storage/service/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "activestorage-horcrux"
|
|
7
|
+
spec.version = ActiveStorage::HorcruxService::VERSION
|
|
8
|
+
spec.authors = ["John Callahan"]
|
|
9
|
+
spec.email = ["jcallahan@acm.org"]
|
|
10
|
+
|
|
11
|
+
spec.summary = 'The Horcrux Protocol as an Active Storage service'
|
|
12
|
+
spec.description = 'Splits uploads using Shamir Secret Sharing across one or more other Active Storage services'
|
|
13
|
+
spec.homepage = "https://github.com/johncallahan/activestorage-horcrux"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
20
|
+
end
|
|
21
|
+
spec.bindir = "exe"
|
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.17.3"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
28
|
+
spec.add_development_dependency "coveralls", "~> 0.8.22"
|
|
29
|
+
spec.add_development_dependency "rails", "~> 5.2"
|
|
30
|
+
spec.add_development_dependency "tss", "~> 0.4.0"
|
|
31
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "active_storage/service/dropbox_service"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tss'
|
|
4
|
+
require 'base64'
|
|
5
|
+
require "active_support/core_ext/module/delegation"
|
|
6
|
+
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
module ActiveStorage
|
|
10
|
+
class Service::HorcruxService < Service
|
|
11
|
+
attr_reader :services, :shares, :threshold
|
|
12
|
+
|
|
13
|
+
def upload(key,io,checksum: nil, **options)
|
|
14
|
+
data = io.tap(&:rewind).read
|
|
15
|
+
base64Data = Base64.encode64(data)
|
|
16
|
+
shards = TSS.split(secret: base64Data,threshold: @threshold,num_shares: @shares)
|
|
17
|
+
i = 0
|
|
18
|
+
servicesamples = []
|
|
19
|
+
file = Tempfile.new(key,"/tmp")
|
|
20
|
+
while i < shards.count
|
|
21
|
+
if servicesamples.empty?
|
|
22
|
+
servicesamples = services[0..-1]
|
|
23
|
+
end
|
|
24
|
+
svc = servicesamples.sample
|
|
25
|
+
shardkey = SecureRandom.base58(key.length)
|
|
26
|
+
svc.upload shardkey, StringIO.new(shards[i]), checksum: nil, **options
|
|
27
|
+
file.write("#{shardkey},")
|
|
28
|
+
servicesamples.delete(svc)
|
|
29
|
+
i = i + 1
|
|
30
|
+
end
|
|
31
|
+
file.close
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def download(keys,&block)
|
|
35
|
+
shardkeys = keys.split(',')
|
|
36
|
+
shards = []
|
|
37
|
+
i = 0
|
|
38
|
+
while i < shardkeys.count
|
|
39
|
+
j = 0
|
|
40
|
+
while j < services.count
|
|
41
|
+
if services[j].exist?(shardkeys[i])
|
|
42
|
+
shards << services[j].download(shardkeys[i])
|
|
43
|
+
end
|
|
44
|
+
j = j + 1
|
|
45
|
+
end
|
|
46
|
+
i = i + 1
|
|
47
|
+
end
|
|
48
|
+
secret = TSS.combine(shares: shards)
|
|
49
|
+
if block_given?
|
|
50
|
+
yield Base64.decode64(secret[:secret])
|
|
51
|
+
else
|
|
52
|
+
return Base64.decode64(secret[:secret])
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def download_chunk(keys, range)
|
|
57
|
+
raise ActiveStorage::UnpreviewableError, "Horcrux does not implement ranged download yet"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def delete(*args)
|
|
61
|
+
perform_across_services(:delete, *args)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Stitch together from named services.
|
|
65
|
+
def self.build(services:, shares:, threshold:, configurator:, **options) #:nodoc:
|
|
66
|
+
new \
|
|
67
|
+
shares: shares,
|
|
68
|
+
threshold: threshold,
|
|
69
|
+
services: services.collect { |name| configurator.build name }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def initialize(shares:,threshold:,services:)
|
|
73
|
+
@shares, @threshold, @services = shares, threshold, services
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def delete_prefixed(*args)
|
|
77
|
+
raise ActiveStorage::UnpreviewableError, "Horcrux does not implement delete by prefix yet"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def exist?(keys)
|
|
81
|
+
localKeys = keys.split(',')
|
|
82
|
+
i = 0
|
|
83
|
+
while i < localKeys.count
|
|
84
|
+
j = 0
|
|
85
|
+
while j < services.count
|
|
86
|
+
if services[j].exist?(localKeys[i])
|
|
87
|
+
return true
|
|
88
|
+
end
|
|
89
|
+
j = j + 1
|
|
90
|
+
end
|
|
91
|
+
i = i + 1
|
|
92
|
+
end
|
|
93
|
+
return false
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def url(*args)
|
|
97
|
+
raise ActiveStorage::UnpreviewableError, "Horcrux does not implement url yet"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def path_for(*args)
|
|
101
|
+
raise ActiveStorage::UnpreviewableError, "Horcrux does not implement path_for yet"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
def each_service(&block)
|
|
107
|
+
[ *services ].each(&block)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def perform_across_services(method, *args)
|
|
111
|
+
# FIXME: Convert to be threaded
|
|
112
|
+
each_service.collect do |service|
|
|
113
|
+
service.public_send method, *args
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: activestorage-horcrux
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- John Callahan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-08-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 1.17.3
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 1.17.3
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: coveralls
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.8.22
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.8.22
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rails
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '5.2'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '5.2'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: tss
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.4.0
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.4.0
|
|
97
|
+
description: Splits uploads using Shamir Secret Sharing across one or more other Active
|
|
98
|
+
Storage services
|
|
99
|
+
email:
|
|
100
|
+
- jcallahan@acm.org
|
|
101
|
+
executables: []
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".coveralls.yml"
|
|
106
|
+
- ".gitignore"
|
|
107
|
+
- ".rspec"
|
|
108
|
+
- ".travis.yml"
|
|
109
|
+
- CODE_OF_CONDUCT.md
|
|
110
|
+
- Gemfile
|
|
111
|
+
- Gemfile.lock
|
|
112
|
+
- LICENSE.txt
|
|
113
|
+
- README.md
|
|
114
|
+
- Rakefile
|
|
115
|
+
- activestorage-horcrux.gemspec
|
|
116
|
+
- bin/console
|
|
117
|
+
- bin/setup
|
|
118
|
+
- lib/active_storage/service/horcrux_service.rb
|
|
119
|
+
- lib/active_storage/service/version.rb
|
|
120
|
+
homepage: https://github.com/johncallahan/activestorage-horcrux
|
|
121
|
+
licenses:
|
|
122
|
+
- MIT
|
|
123
|
+
metadata: {}
|
|
124
|
+
post_install_message:
|
|
125
|
+
rdoc_options: []
|
|
126
|
+
require_paths:
|
|
127
|
+
- lib
|
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
requirements: []
|
|
139
|
+
rubygems_version: 3.0.6
|
|
140
|
+
signing_key:
|
|
141
|
+
specification_version: 4
|
|
142
|
+
summary: The Horcrux Protocol as an Active Storage service
|
|
143
|
+
test_files: []
|