conjur-asset-key-pair 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.project +18 -0
  4. data/.rvmrc +1 -0
  5. data/Gemfile +16 -0
  6. data/Gemfile.lock +214 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +27 -0
  10. data/app/controllers/key_pairs_controller.rb +30 -0
  11. data/app/models/key_pair.rb +55 -0
  12. data/config/routes.rb +8 -0
  13. data/conjur-asset-key-pair.gemspec +48 -0
  14. data/db/migrate/20121219081344_slosilo_keystore.rb +1 -0
  15. data/db/migrate/20130206195553_create_random_id_functions.rb +9 -0
  16. data/db/migrate/20130513145031_create_key_pairs.rb +18 -0
  17. data/features/key_pair_create.feature +21 -0
  18. data/features/key_pair_roles.feature +46 -0
  19. data/features/support/env.rb +87 -0
  20. data/features/support/hooks.rb +22 -0
  21. data/lib/conjur-asset-key-pair-version.rb +7 -0
  22. data/lib/conjur-asset-key-pair.rb +5 -0
  23. data/lib/conjur/api/key_pairs.rb +13 -0
  24. data/lib/conjur/asset/key-pair/cucumber/key_pair_steps.rb +24 -0
  25. data/lib/conjur/asset/key-pair/cucumber/steps.rb +1 -0
  26. data/lib/conjur/asset/key-pair/engine.rb +8 -0
  27. data/lib/conjur/command/key_pairs.rb +28 -0
  28. data/lib/conjur/key-pair-api.rb +13 -0
  29. data/lib/conjur/key_pair.rb +15 -0
  30. data/spec/dummy/README.rdoc +261 -0
  31. data/spec/dummy/Rakefile +7 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  33. data/spec/dummy/config.ru +4 -0
  34. data/spec/dummy/config/application.rb +64 -0
  35. data/spec/dummy/config/boot.rb +10 -0
  36. data/spec/dummy/config/database.yml +19 -0
  37. data/spec/dummy/config/environment.rb +5 -0
  38. data/spec/dummy/config/environments/cucumber.rb +40 -0
  39. data/spec/dummy/config/environments/development.rb +37 -0
  40. data/spec/dummy/config/environments/test.rb +38 -0
  41. data/spec/dummy/config/initializers/authenticator.rb +5 -0
  42. data/spec/dummy/config/initializers/conjur.rb +6 -0
  43. data/spec/dummy/config/locales/en.yml +5 -0
  44. data/spec/dummy/config/routes.rb +58 -0
  45. data/spec/dummy/db/schema.rb +24 -0
  46. data/spec/dummy/log/.gitkeep +0 -0
  47. data/spec/dummy/script/rails +6 -0
  48. data/spec/models/key_pair_spec.rb +117 -0
  49. data/spec/spec_helper.rb +54 -0
  50. metadata +273 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 905d882153a79ca22feef6527d21c18919211315
4
+ data.tar.gz: 3c166a28a40fed8bae0a8f565faa5e5458da7ebc
5
+ SHA512:
6
+ metadata.gz: 835156c879ff781ba618f8608eb4b7d4d2da2f331f5a113436b1412e26840ba3dcefe607b1c9d562e191262b45582f510582bca3e3faea0198e9c9eb202f6df7
7
+ data.tar.gz: 852aa4d2063284f4049b873c4f7f585ef648606fe363bd970f45e42635938c60c57c7282dc1a54f93b709ba3128ac58cb041ee36617b7f7dd16cb5a9241d136c
@@ -0,0 +1,8 @@
1
+ coverage
2
+ .bundle/
3
+ log/*.log
4
+ pkg/
5
+ spec/dummy/db/*.sqlite3
6
+ spec/dummy/log/*.log
7
+ spec/dummy/tmp/
8
+ spec/dummy/.sass-cache
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>conjur-asset-key-pair</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.aptana.ide.core.unifiedBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>com.aptana.ruby.core.rubynature</nature>
16
+ <nature>com.aptana.projects.webnature</nature>
17
+ </natures>
18
+ </projectDescription>
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 2.0.0@conjur-asset-key-pair
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in conjur-asset-service-gateway.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ gem 'rails-api'
9
+ gem 'webmock'
10
+ gem 'rspec-rails'
11
+ gem 'selenium-webdriver'
12
+
13
+ gem 'authable', git: 'https://inscitiv-ops-dev:Me5aswes@github.com/inscitiv/authable.git', branch: 'master'
14
+ gem 'conjur-api', git: 'https://github.com/inscitiv/api-ruby.git', branch: 'master'
15
+ gem 'slosilo'
16
+ gem 'sequel-rails', git: 'git://github.com/dividedmind/sequel-rails.git', branch: 'max-connections'
@@ -0,0 +1,214 @@
1
+ GIT
2
+ remote: git://github.com/dividedmind/sequel-rails.git
3
+ revision: a5c7454d239cba14993a9ff95fee0ab1556864d6
4
+ branch: max-connections
5
+ specs:
6
+ sequel-rails (0.4.3)
7
+ railties (>= 3.2.0)
8
+ sequel (~> 3.28)
9
+
10
+ GIT
11
+ remote: https://github.com/inscitiv/api-ruby.git
12
+ revision: 90dcd6174deb3369e9c4680f9fc4721a6e19394a
13
+ branch: master
14
+ specs:
15
+ conjur-api (2.4.0)
16
+ activesupport
17
+ rest-client
18
+
19
+ GIT
20
+ remote: https://inscitiv-ops-dev:Me5aswes@github.com/inscitiv/authable.git
21
+ revision: 3f3680aa5f966e2d7f7bafcb1d25012174cc73a5
22
+ branch: master
23
+ specs:
24
+ authable (0.2.0)
25
+ activesupport
26
+ conjur-api
27
+ slosilo
28
+
29
+ PATH
30
+ remote: .
31
+ specs:
32
+ conjur-asset-key-pair (0.2.1)
33
+ conjur-api
34
+
35
+ GEM
36
+ remote: http://rubygems.org/
37
+ specs:
38
+ actionmailer (3.2.13)
39
+ actionpack (= 3.2.13)
40
+ mail (~> 2.5.3)
41
+ actionpack (3.2.13)
42
+ activemodel (= 3.2.13)
43
+ activesupport (= 3.2.13)
44
+ builder (~> 3.0.0)
45
+ erubis (~> 2.7.0)
46
+ journey (~> 1.0.4)
47
+ rack (~> 1.4.5)
48
+ rack-cache (~> 1.2)
49
+ rack-test (~> 0.6.1)
50
+ sprockets (~> 2.2.1)
51
+ activemodel (3.2.13)
52
+ activesupport (= 3.2.13)
53
+ builder (~> 3.0.0)
54
+ activerecord (3.2.13)
55
+ activemodel (= 3.2.13)
56
+ activesupport (= 3.2.13)
57
+ arel (~> 3.0.2)
58
+ tzinfo (~> 0.3.29)
59
+ activeresource (3.2.13)
60
+ activemodel (= 3.2.13)
61
+ activesupport (= 3.2.13)
62
+ activesupport (3.2.13)
63
+ i18n (= 0.6.1)
64
+ multi_json (~> 1.0)
65
+ addressable (2.3.5)
66
+ arel (3.0.2)
67
+ builder (3.0.4)
68
+ capybara (2.1.0)
69
+ mime-types (>= 1.16)
70
+ nokogiri (>= 1.3.3)
71
+ rack (>= 1.0.0)
72
+ rack-test (>= 0.5.4)
73
+ xpath (~> 2.0)
74
+ childprocess (0.3.9)
75
+ ffi (~> 1.0, >= 1.0.11)
76
+ ci_reporter (1.8.4)
77
+ builder (>= 2.1.2)
78
+ crack (0.4.0)
79
+ safe_yaml (~> 0.9.0)
80
+ cucumber (1.3.2)
81
+ builder (>= 2.1.2)
82
+ diff-lcs (>= 1.1.3)
83
+ gherkin (~> 2.12.0)
84
+ multi_json (~> 1.3)
85
+ cucumber-rails (1.3.1)
86
+ capybara (>= 1.1.2)
87
+ cucumber (>= 1.2.0)
88
+ nokogiri (>= 1.5.0)
89
+ rails (~> 3.0)
90
+ diff-lcs (1.2.4)
91
+ erubis (2.7.0)
92
+ ffi (1.9.0)
93
+ gherkin (2.12.0)
94
+ multi_json (~> 1.3)
95
+ hike (1.2.3)
96
+ i18n (0.6.1)
97
+ journey (1.0.4)
98
+ json (1.8.0)
99
+ json_spec (1.1.1)
100
+ multi_json (~> 1.0)
101
+ rspec (~> 2.0)
102
+ mail (2.5.4)
103
+ mime-types (~> 1.16)
104
+ treetop (~> 1.4.8)
105
+ mime-types (1.23)
106
+ mini_portile (0.5.0)
107
+ multi_json (1.7.7)
108
+ nokogiri (1.6.0)
109
+ mini_portile (~> 0.5.0)
110
+ pg (0.15.1)
111
+ pg_random_id (1.0.0)
112
+ polyglot (0.3.3)
113
+ rack (1.4.5)
114
+ rack-cache (1.2)
115
+ rack (>= 0.4)
116
+ rack-ssl (1.3.3)
117
+ rack
118
+ rack-test (0.6.2)
119
+ rack (>= 1.0)
120
+ rails (3.2.13)
121
+ actionmailer (= 3.2.13)
122
+ actionpack (= 3.2.13)
123
+ activerecord (= 3.2.13)
124
+ activeresource (= 3.2.13)
125
+ activesupport (= 3.2.13)
126
+ bundler (~> 1.0)
127
+ railties (= 3.2.13)
128
+ rails-api (0.1.0)
129
+ actionpack (>= 3.2.11)
130
+ railties (>= 3.2.11)
131
+ tzinfo (~> 0.3.31)
132
+ railties (3.2.13)
133
+ actionpack (= 3.2.13)
134
+ activesupport (= 3.2.13)
135
+ rack-ssl (~> 1.3.2)
136
+ rake (>= 0.8.7)
137
+ rdoc (~> 3.4)
138
+ thor (>= 0.14.6, < 2.0)
139
+ rake (10.1.0)
140
+ rdoc (3.12.2)
141
+ json (~> 1.4)
142
+ rest-client (1.6.7)
143
+ mime-types (>= 1.16)
144
+ rspec (2.13.0)
145
+ rspec-core (~> 2.13.0)
146
+ rspec-expectations (~> 2.13.0)
147
+ rspec-mocks (~> 2.13.0)
148
+ rspec-core (2.13.1)
149
+ rspec-expectations (2.13.0)
150
+ diff-lcs (>= 1.1.3, < 2.0)
151
+ rspec-mocks (2.13.1)
152
+ rspec-rails (2.13.2)
153
+ actionpack (>= 3.0)
154
+ activesupport (>= 3.0)
155
+ railties (>= 3.0)
156
+ rspec-core (~> 2.13.0)
157
+ rspec-expectations (~> 2.13.0)
158
+ rspec-mocks (~> 2.13.0)
159
+ rubyzip (0.9.9)
160
+ safe_yaml (0.9.3)
161
+ selenium-webdriver (2.33.0)
162
+ childprocess (>= 0.2.5)
163
+ multi_json (~> 1.0)
164
+ rubyzip
165
+ websocket (~> 1.0.4)
166
+ sequel (3.48.0)
167
+ simplecov (0.7.1)
168
+ multi_json (~> 1.0)
169
+ simplecov-html (~> 0.7.1)
170
+ simplecov-html (0.7.1)
171
+ slosilo (0.2.4)
172
+ spork (0.9.2)
173
+ sprockets (2.2.2)
174
+ hike (~> 1.2)
175
+ multi_json (~> 1.0)
176
+ rack (~> 1.0)
177
+ tilt (~> 1.1, != 1.3.0)
178
+ talentbox-sequel-rails (0.3.10)
179
+ railties (~> 3.2.0)
180
+ sequel (~> 3.28)
181
+ thor (0.18.1)
182
+ tilt (1.4.1)
183
+ treetop (1.4.14)
184
+ polyglot
185
+ polyglot (>= 0.3.1)
186
+ tzinfo (0.3.37)
187
+ webmock (1.12.3)
188
+ addressable (>= 2.2.7)
189
+ crack (>= 0.3.2)
190
+ websocket (1.0.7)
191
+ xpath (2.0.0)
192
+ nokogiri (~> 1.3)
193
+
194
+ PLATFORMS
195
+ ruby
196
+
197
+ DEPENDENCIES
198
+ authable!
199
+ ci_reporter
200
+ conjur-api!
201
+ conjur-asset-key-pair!
202
+ cucumber-rails
203
+ json_spec
204
+ pg
205
+ pg_random_id
206
+ rails-api
207
+ rspec-rails
208
+ selenium-webdriver
209
+ sequel-rails!
210
+ simplecov
211
+ slosilo
212
+ spork
213
+ talentbox-sequel-rails
214
+ webmock
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = ConjurAssetDeployment
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ConjurAssetService'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,30 @@
1
+ class KeyPairsController < ApplicationController
2
+ include Authable::Rails::AuthableController
3
+ include Authable::Rails::AuthableCRUD
4
+
5
+ before_filter :find_key_pair, only: [ :show, :encrypt, :decrypt ]
6
+
7
+ def create
8
+ create_record do
9
+ new_record whitelist: [ :id ]
10
+ end
11
+ end
12
+
13
+ # Permissions checking is gated by access to the public key.
14
+ def encrypt
15
+ value = request.body.read
16
+ render text: @key_pair.encrypt(value)
17
+ end
18
+
19
+ # Permissions checking is gated by access to the private key.
20
+ def decrypt
21
+ value = request.body.read
22
+ render text: @key_pair.decrypt(value)
23
+ end
24
+
25
+ protected
26
+
27
+ def find_key_pair
28
+ @key_pair = KeyPair[params[:id]] or raise RecordNotFound
29
+ end
30
+ end
@@ -0,0 +1,55 @@
1
+ # A public/private key pair.
2
+ class KeyPair < Sequel::Model
3
+ plugin :authable, container: true
4
+ plugin :belongs_to_user
5
+
6
+ role :encrypt, :decrypt
7
+
8
+ def public_json
9
+ super.except(:public_keyid, :private_keyid)
10
+ end
11
+
12
+ def encrypt(value)
13
+ public_key.encrypt_message(value)
14
+ end
15
+
16
+ def decrypt(value)
17
+ private_key.decrypt_message(value)
18
+ end
19
+
20
+ def public_key
21
+ @public_key ||= Slosilo::Key.new authz_api.variable(public_keyid).value
22
+ end
23
+
24
+ def private_key
25
+ @private_key ||= Slosilo::Key.new authz_api.variable(private_keyid).value
26
+ end
27
+
28
+ # @private
29
+ def after_initialize
30
+ super
31
+
32
+ unless self.public_keyid
33
+ @key = Slosilo::Key.new
34
+
35
+ private_key = authz_api.create_variable 'application/x-pem-file', 'rsa-private-key', owner_option
36
+ private_key.add_value @key.key.to_pem
37
+
38
+ public_key = authz_api.create_variable 'application/x-pem-file', 'rsa-public-key', owner_option
39
+ public_key.add_value @key.key.public_key.to_pem
40
+
41
+ self.private_keyid = private_key.id
42
+ self.public_keyid = public_key.id
43
+ end
44
+ end
45
+
46
+ # @private
47
+ def after_create
48
+ super
49
+
50
+ # Encrypt role can execute the public key variable
51
+ # Decrypt role can execute the private key variable
52
+ authz_api.variable(public_keyid).resource.permit :execute, role('encrypt')
53
+ authz_api.variable(private_keyid).resource.permit :execute, role('decrypt')
54
+ end
55
+ end
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ resources :key_pairs, :format => false do
3
+ member do
4
+ post :encrypt
5
+ post :decrypt
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,48 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "conjur-asset-key-pair-version"
5
+
6
+ files = if ENV['API_ONLY']
7
+ exclude_dirs = [ ".project", ".rvmrc", "lib/conjur/asset", "config", "db", "features", "spec", "app" ]
8
+ `git ls-files`.split("\n").select do |f|
9
+ exclude_dirs.find{|d| f.index(d) == 0}.nil?
10
+ end.tap do |files|
11
+ puts "Packaging #{files.join(" ")}"
12
+ end
13
+ else
14
+ `git ls-files`.split($/)
15
+ end
16
+
17
+ name = if ENV['API_ONLY']
18
+ "conjur-asset-key-pair-api"
19
+ else
20
+ "conjur-asset-key-pair"
21
+ end
22
+
23
+ # Describe your gem and declare its dependencies:
24
+ Gem::Specification.new do |s|
25
+ s.name = name
26
+ s.version = Conjur::Asset::KeyPair::VERSION
27
+ s.authors = ["Kevin Gilpin"]
28
+ s.email = ["kgilpin@gmail.com"]
29
+ s.homepage = "http://conjur.net"
30
+ s.summary = "Conjur asset plugin for RSA key pairs."
31
+
32
+ s.files = files
33
+
34
+ s.add_dependency "conjur-api"
35
+
36
+ s.add_development_dependency "authable"
37
+ s.add_development_dependency "rails-api"
38
+ s.add_development_dependency "talentbox-sequel-rails"
39
+ s.add_development_dependency "pg"
40
+ s.add_development_dependency "pg_random_id"
41
+ s.add_development_dependency "rspec-rails"
42
+ s.add_development_dependency "cucumber-rails"
43
+ s.add_development_dependency "spork"
44
+ s.add_development_dependency "simplecov"
45
+ s.add_development_dependency "webmock"
46
+ s.add_development_dependency "json_spec"
47
+ s.add_development_dependency "ci_reporter"
48
+ end