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 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 SOURCE_SECRET=the_source_secret
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
- source_secret = ENV['SOURCE_SECRET'] || store.generate_secret
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
@@ -1,3 +1,3 @@
1
1
  module SecretService
2
- VERSION = "0.1.0" unless defined?(SecretService::VERSION)
2
+ VERSION = "0.1.1" unless defined?(SecretService::VERSION)
3
3
  end
@@ -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 given key' do
29
- output = execute_rake('secret_service:store', :puts => 'the_secret')
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', :env => {'SOURCE_SECRET' => 'source_secret'}, :puts => 'the_secret')
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
- hash: 27
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
- date: 2013-03-08 00:00:00 +01:00
19
- default_executable:
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
- prerelease: false
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
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- description: Secret service provides encryption of your application secrets with a server side master password
36
- email:
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
- has_rdoc: true
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
- hash: 3
135
- segments:
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
- hash: 3
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.3.9.5
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 side master password
154
- test_files:
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