secret_service 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -2
- data/lib/secret_service/capistrano.rb +27 -0
- data/lib/secret_service/rake_tasks.rb +7 -1
- data/lib/secret_service/version.rb +1 -1
- data/spec/shared/secret_service/rake_tasks_spec.rb +9 -6
- metadata +40 -55
data/README.md
CHANGED
@@ -47,14 +47,25 @@ If you want to use a specific secret, you can put it into the database by callin
|
|
47
47
|
|
48
48
|
rake secret_service:store
|
49
49
|
|
50
|
-
The secret will be read from STDIN.
|
50
|
+
The secret you'll put into your code as well as the final secret that will be returned are read from STDIN. You can leave the first one blank to have it generated automatically.
|
51
51
|
|
52
52
|
To show a previously stored secret, use
|
53
53
|
|
54
|
-
rake secret_service:show
|
54
|
+
rake secret_service:show
|
55
55
|
|
56
56
|
where `the_source_secret` is the secret used in the `SecretService.secret(...)` call
|
57
57
|
|
58
|
+
## Capistrano integration
|
59
|
+
|
60
|
+
To get capistrano integration, put this into your `config/deploy.rb`:
|
61
|
+
|
62
|
+
require 'secret_service/capistrano'
|
63
|
+
|
64
|
+
You'll get the two rake tasks as corresponding capistrano tasks:
|
65
|
+
|
66
|
+
cap secret_service:store
|
67
|
+
cap secret_service:show
|
68
|
+
|
58
69
|
## Contributing
|
59
70
|
|
60
71
|
1. Fork it
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :secret_service do
|
2
|
+
|
3
|
+
def _run_with_prompt(command)
|
4
|
+
run command do |input, stream, out|
|
5
|
+
puts out
|
6
|
+
if stream == :out and out =~ /^Enter/
|
7
|
+
input.send_data STDIN.gets
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Store a secret using secret_service"
|
13
|
+
task :store, :roles => :db, :only => { :primary => true } do
|
14
|
+
rake = fetch(:rake, "rake")
|
15
|
+
rails_env = fetch(:rails_env, "production")
|
16
|
+
|
17
|
+
_run_with_prompt("cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} secret_service:store")
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Show a secret previously stored with secret_service"
|
21
|
+
task :show, :roles => :db, :only => { :primary => true } do
|
22
|
+
rake = fetch(:rake, "rake")
|
23
|
+
rails_env = fetch(:rails_env, "production")
|
24
|
+
|
25
|
+
_run_with_prompt("cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} secret_service:show")
|
26
|
+
end
|
27
|
+
end
|
@@ -2,7 +2,13 @@ namespace :secret_service do
|
|
2
2
|
desc 'Store a desired secret in the database'
|
3
3
|
task :store => :environment do
|
4
4
|
store = SecretService::Store.new
|
5
|
-
|
5
|
+
|
6
|
+
puts "Enter source secret (as given in your source code; leave blank to auto-generate):"
|
7
|
+
source_secret = STDIN.gets.chomp
|
8
|
+
|
9
|
+
if source_secret == ''
|
10
|
+
source_secret = store.generate_secret
|
11
|
+
end
|
6
12
|
|
7
13
|
puts "Enter secret:"
|
8
14
|
final_secret = STDIN.gets.chomp
|
@@ -5,9 +5,6 @@ describe 'Rake tasks' do
|
|
5
5
|
|
6
6
|
def execute_rake(task, options = {})
|
7
7
|
env = "BUNDLE_GEMFILE=#{File.expand_path(File.join(Rails.root, '..', 'Gemfile'))}"
|
8
|
-
options.fetch(:env, {}).each do |key, value|
|
9
|
-
env << " #{key}=#{value}"
|
10
|
-
end
|
11
8
|
# this is the only way I could make it work in ruby 1.8 and 1.9
|
12
9
|
Open3.popen3("bash -c 'cd #{Rails.root}; #{env} bundle exec rake #{task}'") do |stdin, stdout, stderr, wait_thr|
|
13
10
|
if options[:puts]
|
@@ -25,14 +22,20 @@ describe 'Rake tasks' do
|
|
25
22
|
|
26
23
|
describe 'store' do
|
27
24
|
|
28
|
-
it 'should store the prompted secret under the
|
29
|
-
output = execute_rake('secret_service:store', :puts =>
|
25
|
+
it 'should store the prompted secret under the returned key' do
|
26
|
+
output = execute_rake('secret_service:store', :puts => "\nthe_secret")
|
30
27
|
(output =~ /SecretService\.secret\("(.*)"\)/).should be_true
|
31
28
|
SecretService.secret($1).should == 'the_secret'
|
32
29
|
end
|
33
30
|
|
31
|
+
it 'should generate a sensible source secret' do
|
32
|
+
output = execute_rake('secret_service:store', :puts => "\nthe_secret")
|
33
|
+
(output =~ /SecretService\.secret\("(.*)"\)/).should be_true
|
34
|
+
$1.size.should > 20
|
35
|
+
end
|
36
|
+
|
34
37
|
it 'should allow to set the source secret' do
|
35
|
-
output = execute_rake('secret_service:store', :
|
38
|
+
output = execute_rake('secret_service:store', :puts => "source_secret\nthe_secret")
|
36
39
|
output.should =~ /SecretService\.secret\("source_secret"\)/
|
37
40
|
end
|
38
41
|
|
metadata
CHANGED
@@ -1,47 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret_service
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Tobias Kraze
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: gibberish
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Secret service provides encryption of your application secrets with a
|
31
|
+
server side master password
|
32
|
+
email:
|
37
33
|
- tobias@kraze.eu
|
38
34
|
executables: []
|
39
|
-
|
40
35
|
extensions: []
|
41
|
-
|
42
36
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
37
|
+
files:
|
45
38
|
- .gitignore
|
46
39
|
- .travis.yml
|
47
40
|
- Gemfile
|
@@ -49,6 +42,7 @@ files:
|
|
49
42
|
- README.md
|
50
43
|
- Rakefile
|
51
44
|
- lib/secret_service.rb
|
45
|
+
- lib/secret_service/capistrano.rb
|
52
46
|
- lib/secret_service/database_store.rb
|
53
47
|
- lib/secret_service/database_store/active_record_store.rb
|
54
48
|
- lib/secret_service/rake_tasks.rb
|
@@ -117,41 +111,32 @@ files:
|
|
117
111
|
- spec/shared/secret_service/store_spec.rb
|
118
112
|
- spec/shared/support/reconnect_task.rake
|
119
113
|
- spec/shared/support/wipe_store.rb
|
120
|
-
|
121
|
-
homepage: ""
|
114
|
+
homepage: ''
|
122
115
|
licenses: []
|
123
|
-
|
124
116
|
post_install_message:
|
125
117
|
rdoc_options: []
|
126
|
-
|
127
|
-
require_paths:
|
118
|
+
require_paths:
|
128
119
|
- lib
|
129
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
121
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
|
136
|
-
- 0
|
137
|
-
version: "0"
|
138
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
127
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
version: "0"
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
147
132
|
requirements: []
|
148
|
-
|
149
133
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.8.24
|
151
135
|
signing_key:
|
152
136
|
specification_version: 3
|
153
|
-
summary: Secret service provides encryption of your application secrets with a server
|
154
|
-
|
137
|
+
summary: Secret service provides encryption of your application secrets with a server
|
138
|
+
side master password
|
139
|
+
test_files:
|
155
140
|
- spec/rails-2.3/Gemfile
|
156
141
|
- spec/rails-2.3/Rakefile
|
157
142
|
- spec/rails-2.3/app_root/Rakefile
|