secret_service 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.gitignore +18 -0
  2. data/.travis.yml +15 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +41 -0
  6. data/Rakefile +57 -0
  7. data/lib/secret_service.rb +13 -0
  8. data/lib/secret_service/database_store.rb +5 -0
  9. data/lib/secret_service/database_store/active_record_store.rb +66 -0
  10. data/lib/secret_service/store.rb +35 -0
  11. data/lib/secret_service/version.rb +3 -0
  12. data/secret_service.gemspec +19 -0
  13. data/spec/rails-2.3/Gemfile +10 -0
  14. data/spec/rails-2.3/Rakefile +11 -0
  15. data/spec/rails-2.3/app_root/config/boot.rb +128 -0
  16. data/spec/rails-2.3/app_root/config/database.yml +6 -0
  17. data/spec/rails-2.3/app_root/config/environment.rb +14 -0
  18. data/spec/rails-2.3/app_root/config/environments/test.rb +0 -0
  19. data/spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb +1 -0
  20. data/spec/rails-2.3/app_root/config/preinitializer.rb +20 -0
  21. data/spec/rails-2.3/app_root/config/routes.rb +13 -0
  22. data/spec/rails-2.3/app_root/log/.gitignore +1 -0
  23. data/spec/rails-2.3/rcov.opts +2 -0
  24. data/spec/rails-2.3/spec.opts +4 -0
  25. data/spec/rails-2.3/spec/spec_helper.rb +20 -0
  26. data/spec/rails-3.0/.rspec +2 -0
  27. data/spec/rails-3.0/Gemfile +10 -0
  28. data/spec/rails-3.0/Rakefile +11 -0
  29. data/spec/rails-3.0/app_root/.gitignore +4 -0
  30. data/spec/rails-3.0/app_root/config/application.rb +31 -0
  31. data/spec/rails-3.0/app_root/config/boot.rb +13 -0
  32. data/spec/rails-3.0/app_root/config/database.yml +6 -0
  33. data/spec/rails-3.0/app_root/config/environment.rb +5 -0
  34. data/spec/rails-3.0/app_root/config/environments/test.rb +35 -0
  35. data/spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/rails-3.0/app_root/config/initializers/inflections.rb +10 -0
  37. data/spec/rails-3.0/app_root/config/initializers/mime_types.rb +5 -0
  38. data/spec/rails-3.0/app_root/config/initializers/secret_token.rb +7 -0
  39. data/spec/rails-3.0/app_root/config/initializers/session_store.rb +8 -0
  40. data/spec/rails-3.0/app_root/config/routes.rb +3 -0
  41. data/spec/rails-3.0/app_root/lib/tasks/.gitkeep +0 -0
  42. data/spec/rails-3.0/app_root/log/.gitkeep +0 -0
  43. data/spec/rails-3.0/app_root/script/rails +6 -0
  44. data/spec/rails-3.0/rcov.opts +2 -0
  45. data/spec/rails-3.0/spec/spec_helper.rb +18 -0
  46. data/spec/rails-3.2/.rspec +2 -0
  47. data/spec/rails-3.2/Gemfile +9 -0
  48. data/spec/rails-3.2/Rakefile +11 -0
  49. data/spec/rails-3.2/app_root/.gitignore +4 -0
  50. data/spec/rails-3.2/app_root/config/application.rb +31 -0
  51. data/spec/rails-3.2/app_root/config/boot.rb +13 -0
  52. data/spec/rails-3.2/app_root/config/database.yml +6 -0
  53. data/spec/rails-3.2/app_root/config/environment.rb +5 -0
  54. data/spec/rails-3.2/app_root/config/environments/test.rb +35 -0
  55. data/spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb +7 -0
  56. data/spec/rails-3.2/app_root/config/initializers/inflections.rb +10 -0
  57. data/spec/rails-3.2/app_root/config/initializers/mime_types.rb +5 -0
  58. data/spec/rails-3.2/app_root/config/initializers/secret_token.rb +7 -0
  59. data/spec/rails-3.2/app_root/config/initializers/session_store.rb +8 -0
  60. data/spec/rails-3.2/app_root/config/routes.rb +3 -0
  61. data/spec/rails-3.2/app_root/log/.gitignore +1 -0
  62. data/spec/rails-3.2/rcov.opts +2 -0
  63. data/spec/rails-3.2/spec/spec_helper.rb +17 -0
  64. data/spec/shared/app_root/app/controllers/application_controller.rb +2 -0
  65. data/spec/shared/app_root/config/database.yml.sample +6 -0
  66. data/spec/shared/app_root/db/consul_test.db +0 -0
  67. data/spec/shared/secret_service/secret_service_spec.rb +24 -0
  68. data/spec/shared/secret_service/store_spec.rb +89 -0
  69. data/spec/shared/support/wipe_store.rb +10 -0
  70. metadata +189 -0
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ SpecApp::Application.config.secret_token = 'cb014a08a45243e7143f31e04774c342c1fba329fd594ae1a480d8283b1a851f425dc08044311fb4be6d000b6e6681de7c76d19148419a5ffa0a9f84556d3b33'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ SpecApp::Application.config.session_store :cookie_store, :key => '_app_root_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # HasDefaultSpecApp::Application.config.session_store :active_record_store
@@ -0,0 +1,3 @@
1
+ SpecApp::Application.routes.draw do
2
+ match ':controller(/:action(/:id(.:format)))'
3
+ end
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --rails
@@ -0,0 +1,17 @@
1
+ $: << File.join(File.dirname(__FILE__), "/../../lib" )
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ ENV['RAILS_ROOT'] = 'app_root'
5
+
6
+ # Load the Rails environment and testing framework
7
+ require "#{File.dirname(__FILE__)}/../app_root/config/environment"
8
+ require 'rspec/rails'
9
+
10
+
11
+ # Requires supporting files with custom matchers and macros, etc in ./support/ and its subdirectories.
12
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
13
+
14
+ RSpec.configure do |config|
15
+ config.use_transactional_fixtures = true
16
+ config.use_instantiated_fixtures = false
17
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,6 @@
1
+ test:
2
+ adapter: mysql2
3
+ host: localhost
4
+ username: root
5
+ password:
6
+ database: secret_service_test
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe SecretService do
4
+
5
+ describe '.secret' do
6
+
7
+ it 'should delegate to the store' do
8
+ SecretService::Store.instance.should_receive(:get).with('source secret').and_return('final secret')
9
+ SecretService.secret('source secret').should == 'final secret'
10
+ end
11
+
12
+ it 'should cache' do
13
+ SecretService::Store.instance.should_receive(:get).exactly(:once).and_return('final secret')
14
+ SecretService.secret('source secret')
15
+ SecretService.secret('source secret')
16
+ end
17
+
18
+ it 'should return the source secret if :plain is true' do
19
+ SecretService.secret('source secret', :plain => true).should == 'source secret'
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe SecretService::Store do
4
+
5
+
6
+ def store
7
+ SecretService::Store.send(:new)
8
+ end
9
+
10
+ describe '#get' do
11
+
12
+ it 'should return long secrets' do
13
+ store.get('foo').size.should > 20
14
+ end
15
+
16
+ it 'should consistently return the same secret' do
17
+ store.get('foobar').should == store.get('foobar')
18
+ end
19
+
20
+ it 'should not return the same secret for different source secrets' do
21
+ store.get('foo').should_not == store.get('bar')
22
+ end
23
+
24
+ it 'should not contain the source secret' do
25
+ store.get('foobarbaz').should_not include('foobarbaz')
26
+ end
27
+
28
+ it 'should return a different secret when the database changes' do
29
+ first_secret = store.get('foo')
30
+ SecretServiceSpec.wipe_store
31
+ store.get('foo').should_not == first_secret
32
+ end
33
+
34
+ it 'should not put the source secret into the database' do
35
+ store.get('foobarbaz')
36
+ secret_record = SecretService::DatabaseStore::ActiveRecordStore::Secret.first
37
+ secret_record.key.should_not include('foobarbaz')
38
+ secret_record.value.should_not include('foobarbaz')
39
+ end
40
+
41
+ it 'should not put the final secret into the database' do
42
+ final_secret = store.get('foobarbaz')
43
+ secret_record = SecretService::DatabaseStore::ActiveRecordStore::Secret.first
44
+ secret_record.key.should_not include(final_secret)
45
+ secret_record.value.should_not include(final_secret)
46
+ end
47
+
48
+ it 'should put long secrets into the database' do
49
+ store.get('foobarbaz')
50
+ secret_record = SecretService::DatabaseStore::ActiveRecordStore::Secret.first
51
+ secret_record.value.size.should > 10
52
+ end
53
+
54
+ context 'concurrency' do
55
+
56
+ def safe_fork
57
+ reader, writer = IO.pipe
58
+ fork do
59
+ ActiveRecord::Base.connection.reconnect!
60
+ reader.close
61
+ yield(writer)
62
+ writer.flush
63
+ writer.close
64
+ Process.exit!
65
+ end
66
+ writer.close
67
+ ActiveRecord::Base.connection.reconnect!
68
+ reader
69
+ end
70
+
71
+
72
+ it 'should work concurrently' do
73
+ readers = []
74
+ 20.times do
75
+ readers << safe_fork do |writer|
76
+ sleep rand(0.1)
77
+ writer.print store.get("foobar")
78
+ end
79
+ end
80
+ lines = readers.collect(&:read)
81
+ lines.size.should == 20
82
+ lines.uniq.should == [store.get("foobar")]
83
+ end
84
+
85
+ end
86
+
87
+ end
88
+
89
+ end
@@ -0,0 +1,10 @@
1
+ module SecretServiceSpec
2
+ def self.wipe_store
3
+ SecretService.instance_variable_set(:@secrets, nil)
4
+ SecretService::DatabaseStore.get.drop_database
5
+ end
6
+ end
7
+
8
+ (defined?(Spec) ? Spec::Runner : RSpec).configure do |config|
9
+ config.before(:each) { SecretServiceSpec.wipe_store }
10
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: secret_service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tobias Kraze
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gibberish
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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:
33
+ - tobias@kraze.eu
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - .travis.yml
40
+ - Gemfile
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - lib/secret_service.rb
45
+ - lib/secret_service/database_store.rb
46
+ - lib/secret_service/database_store/active_record_store.rb
47
+ - lib/secret_service/store.rb
48
+ - lib/secret_service/version.rb
49
+ - secret_service.gemspec
50
+ - spec/rails-2.3/Gemfile
51
+ - spec/rails-2.3/Rakefile
52
+ - spec/rails-2.3/app_root/config/boot.rb
53
+ - spec/rails-2.3/app_root/config/database.yml
54
+ - spec/rails-2.3/app_root/config/environment.rb
55
+ - spec/rails-2.3/app_root/config/environments/test.rb
56
+ - spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb
57
+ - spec/rails-2.3/app_root/config/preinitializer.rb
58
+ - spec/rails-2.3/app_root/config/routes.rb
59
+ - spec/rails-2.3/app_root/log/.gitignore
60
+ - spec/rails-2.3/rcov.opts
61
+ - spec/rails-2.3/spec.opts
62
+ - spec/rails-2.3/spec/spec_helper.rb
63
+ - spec/rails-3.0/.rspec
64
+ - spec/rails-3.0/Gemfile
65
+ - spec/rails-3.0/Rakefile
66
+ - spec/rails-3.0/app_root/.gitignore
67
+ - spec/rails-3.0/app_root/config/application.rb
68
+ - spec/rails-3.0/app_root/config/boot.rb
69
+ - spec/rails-3.0/app_root/config/database.yml
70
+ - spec/rails-3.0/app_root/config/environment.rb
71
+ - spec/rails-3.0/app_root/config/environments/test.rb
72
+ - spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb
73
+ - spec/rails-3.0/app_root/config/initializers/inflections.rb
74
+ - spec/rails-3.0/app_root/config/initializers/mime_types.rb
75
+ - spec/rails-3.0/app_root/config/initializers/secret_token.rb
76
+ - spec/rails-3.0/app_root/config/initializers/session_store.rb
77
+ - spec/rails-3.0/app_root/config/routes.rb
78
+ - spec/rails-3.0/app_root/lib/tasks/.gitkeep
79
+ - spec/rails-3.0/app_root/log/.gitkeep
80
+ - spec/rails-3.0/app_root/script/rails
81
+ - spec/rails-3.0/rcov.opts
82
+ - spec/rails-3.0/spec/spec_helper.rb
83
+ - spec/rails-3.2/.rspec
84
+ - spec/rails-3.2/Gemfile
85
+ - spec/rails-3.2/Rakefile
86
+ - spec/rails-3.2/app_root/.gitignore
87
+ - spec/rails-3.2/app_root/config/application.rb
88
+ - spec/rails-3.2/app_root/config/boot.rb
89
+ - spec/rails-3.2/app_root/config/database.yml
90
+ - spec/rails-3.2/app_root/config/environment.rb
91
+ - spec/rails-3.2/app_root/config/environments/test.rb
92
+ - spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb
93
+ - spec/rails-3.2/app_root/config/initializers/inflections.rb
94
+ - spec/rails-3.2/app_root/config/initializers/mime_types.rb
95
+ - spec/rails-3.2/app_root/config/initializers/secret_token.rb
96
+ - spec/rails-3.2/app_root/config/initializers/session_store.rb
97
+ - spec/rails-3.2/app_root/config/routes.rb
98
+ - spec/rails-3.2/app_root/log/.gitignore
99
+ - spec/rails-3.2/rcov.opts
100
+ - spec/rails-3.2/spec/spec_helper.rb
101
+ - spec/shared/app_root/app/controllers/application_controller.rb
102
+ - spec/shared/app_root/config/database.yml.sample
103
+ - spec/shared/app_root/db/consul_test.db
104
+ - spec/shared/secret_service/secret_service_spec.rb
105
+ - spec/shared/secret_service/store_spec.rb
106
+ - spec/shared/support/wipe_store.rb
107
+ homepage: ''
108
+ licenses: []
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.24
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Secret service provides encryption of your application secrets with a server
131
+ side master password
132
+ test_files:
133
+ - spec/rails-2.3/Gemfile
134
+ - spec/rails-2.3/Rakefile
135
+ - spec/rails-2.3/app_root/config/boot.rb
136
+ - spec/rails-2.3/app_root/config/database.yml
137
+ - spec/rails-2.3/app_root/config/environment.rb
138
+ - spec/rails-2.3/app_root/config/environments/test.rb
139
+ - spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb
140
+ - spec/rails-2.3/app_root/config/preinitializer.rb
141
+ - spec/rails-2.3/app_root/config/routes.rb
142
+ - spec/rails-2.3/app_root/log/.gitignore
143
+ - spec/rails-2.3/rcov.opts
144
+ - spec/rails-2.3/spec.opts
145
+ - spec/rails-2.3/spec/spec_helper.rb
146
+ - spec/rails-3.0/.rspec
147
+ - spec/rails-3.0/Gemfile
148
+ - spec/rails-3.0/Rakefile
149
+ - spec/rails-3.0/app_root/.gitignore
150
+ - spec/rails-3.0/app_root/config/application.rb
151
+ - spec/rails-3.0/app_root/config/boot.rb
152
+ - spec/rails-3.0/app_root/config/database.yml
153
+ - spec/rails-3.0/app_root/config/environment.rb
154
+ - spec/rails-3.0/app_root/config/environments/test.rb
155
+ - spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb
156
+ - spec/rails-3.0/app_root/config/initializers/inflections.rb
157
+ - spec/rails-3.0/app_root/config/initializers/mime_types.rb
158
+ - spec/rails-3.0/app_root/config/initializers/secret_token.rb
159
+ - spec/rails-3.0/app_root/config/initializers/session_store.rb
160
+ - spec/rails-3.0/app_root/config/routes.rb
161
+ - spec/rails-3.0/app_root/lib/tasks/.gitkeep
162
+ - spec/rails-3.0/app_root/log/.gitkeep
163
+ - spec/rails-3.0/app_root/script/rails
164
+ - spec/rails-3.0/rcov.opts
165
+ - spec/rails-3.0/spec/spec_helper.rb
166
+ - spec/rails-3.2/.rspec
167
+ - spec/rails-3.2/Gemfile
168
+ - spec/rails-3.2/Rakefile
169
+ - spec/rails-3.2/app_root/.gitignore
170
+ - spec/rails-3.2/app_root/config/application.rb
171
+ - spec/rails-3.2/app_root/config/boot.rb
172
+ - spec/rails-3.2/app_root/config/database.yml
173
+ - spec/rails-3.2/app_root/config/environment.rb
174
+ - spec/rails-3.2/app_root/config/environments/test.rb
175
+ - spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb
176
+ - spec/rails-3.2/app_root/config/initializers/inflections.rb
177
+ - spec/rails-3.2/app_root/config/initializers/mime_types.rb
178
+ - spec/rails-3.2/app_root/config/initializers/secret_token.rb
179
+ - spec/rails-3.2/app_root/config/initializers/session_store.rb
180
+ - spec/rails-3.2/app_root/config/routes.rb
181
+ - spec/rails-3.2/app_root/log/.gitignore
182
+ - spec/rails-3.2/rcov.opts
183
+ - spec/rails-3.2/spec/spec_helper.rb
184
+ - spec/shared/app_root/app/controllers/application_controller.rb
185
+ - spec/shared/app_root/config/database.yml.sample
186
+ - spec/shared/app_root/db/consul_test.db
187
+ - spec/shared/secret_service/secret_service_spec.rb
188
+ - spec/shared/secret_service/store_spec.rb
189
+ - spec/shared/support/wipe_store.rb