conjur-asset-layer-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3de3786e1b6d8e1657ea09179da2b0f56d495978
4
+ data.tar.gz: e297a4d831893c69835df270e9d1f65925ac1b2e
5
+ SHA512:
6
+ metadata.gz: 20739cb7675146ff5bea44a829ec6555e297a6ff25109bf5b842b0b58721193d6561c383ab97bcd5f7feaa5d7aceb8a8043aa953744bf10d4b39189198674494
7
+ data.tar.gz: 142fcbf02addfe6a8ab51ca31d0bc43e8bc0d816f709ebf76fa2a4c134f84d2585204780b8abfeb9aea1923c06bb691433c3f47336b3fde95ad70318e735c0e4
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ Gemfile.lock
2
+ coverage
3
+ .bundle/
4
+ log/*.log
5
+ pkg/
6
+ spec/dummy/db/*.sqlite3
7
+ spec/dummy/db/schema.rb
8
+ spec/dummy/log/*.log
9
+ spec/dummy/tmp/
10
+ spec/dummy/.sass-cache
data/MIT-LICENSE ADDED
@@ -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.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = ConjurAssetDeployment
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -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,56 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "conjur-asset-layer-version"
5
+
6
+ files = if ENV['API_ONLY']
7
+ exclude_dirs = [ "Gemfile", ".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, environment_gem = if ENV['API_ONLY']
18
+ [
19
+ "conjur-asset-layer-api",
20
+ "conjur-asset-environment-api"
21
+ ]
22
+ else
23
+ [
24
+ "conjur-asset-layer",
25
+ "conjur-asset-environment"
26
+ ]
27
+ end
28
+
29
+ # Describe your gem and declare its dependencies:
30
+ Gem::Specification.new do |s|
31
+ s.name = name
32
+ s.version = Conjur::Asset::Layer::VERSION
33
+ s.authors = ["Kevin Gilpin"]
34
+ s.email = ["kgilpin@gmail.com"]
35
+ s.homepage = "http://conjur.net"
36
+ s.summary = "Conjur asset plugin for a deployment layer."
37
+
38
+ s.files = files
39
+
40
+ s.add_dependency "conjur-api"
41
+ s.add_dependency environment_gem
42
+
43
+ s.add_development_dependency "authable"
44
+ s.add_development_dependency "rails-api"
45
+ s.add_development_dependency "talentbox-sequel-rails"
46
+ s.add_development_dependency "pg"
47
+ s.add_development_dependency "pg_random_id"
48
+ s.add_development_dependency "sequel-attribute_callbacks"
49
+ s.add_development_dependency "rspec-rails"
50
+ s.add_development_dependency "cucumber-rails"
51
+ s.add_development_dependency "spork"
52
+ s.add_development_dependency "simplecov"
53
+ s.add_development_dependency "webmock"
54
+ s.add_development_dependency "json_spec"
55
+ s.add_development_dependency "ci_reporter"
56
+ end
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
5
+
6
+ rvm use 2.0.0@conjur-asset-layer
7
+
8
+ # Bootstrap
9
+ WORKDIR=$1
10
+
11
+ if [ -z "$WORKDIR" ] ; then
12
+ echo "Usage: $0 <target_directory>"
13
+ exit 1
14
+ else
15
+ echo "Generating new assets, info stored in $WORKDIR"
16
+ if [ ! -d $WORKDIR ] ; then
17
+ mkdir -v $WORKDIR
18
+ fi
19
+ fi
20
+
21
+ cd $WORKDIR
22
+
23
+ export CONJURAPI_LOG=stderr
24
+
25
+ # Preliminary setup
26
+ ns=`conjur id:create | tee ns`
27
+
28
+ conjur user:create $ns-admin --no-password > admin.json
29
+ conjur group:create $ns/admin > /dev/null
30
+ conjur group:create $ns/users > /dev/null
31
+
32
+ conjur asset:create --as-group $ns/users layer $ns/layer > /dev/null
33
+
34
+ hosta=`conjur host:create $ns/host-a | tee host-a.json | jsonfield id`
35
+ hostb=`conjur host:create $ns/host-b | tee host-b.json | jsonfield id`
36
+
37
+ conjur layer:hosts:add $ns/layer $hosta
38
+ conjur layer:hosts:add $ns/layer $hostb
39
+
@@ -0,0 +1,7 @@
1
+ module Conjur
2
+ module Asset
3
+ module Layer
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require "conjur-asset-layer-version"
2
+ require "conjur/api"
3
+ require "conjur/layer-api"
4
+
5
+ require "conjur/asset/layer/engine" if defined?(Rails) && ENV['CONJUR_ASSET_SERVICE']
@@ -0,0 +1,17 @@
1
+ require 'conjur/layer'
2
+
3
+ module Conjur
4
+ class API
5
+ def create_layer(id, options = {})
6
+ standard_create Conjur::Layers::API.host, :layer, id, options
7
+ end
8
+
9
+ def layers(options = {})
10
+ standard_list Conjur::Layers::API.host, :layer, options
11
+ end
12
+
13
+ def layer id
14
+ standard_show Conjur::Layers::API.host, :layer, id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ require 'conjur/command'
2
+
3
+ class Conjur::Command::Layers < Conjur::Command
4
+ self.prefix = :layer
5
+
6
+ # Form an account:kind:hostid from the host argument
7
+ # Or interpret a fully-qualified role id
8
+ def require_hostid_arg(args)
9
+ hostid = require_arg(args, 'host')
10
+ if hostid.index(':') == 0
11
+ hostid = [ Conjur::Core::API.conjur_account, 'host', hostid ].join(':')
12
+ end
13
+ hostid
14
+ end
15
+
16
+ desc "Add a host to an layer"
17
+ arg_name "layer host"
18
+ command :"hosts:add" do |c|
19
+ c.action do |global_options, options, args|
20
+ id = require_arg(args, 'layer')
21
+ hostid = require_hostid_arg(args)
22
+
23
+ api.layer(id).add_host hostid
24
+ end
25
+ end
26
+
27
+ desc "Remove a host from an layer"
28
+ arg_name "layer host"
29
+ command :"hosts:remove" do |c|
30
+ c.action do |global_options, options, args|
31
+ id = require_arg(args, 'layer')
32
+ hostid = require_hostid_arg(args)
33
+
34
+ api.layer(id).remove_host hostid
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ module Conjur
2
+ module Layers
3
+ class API < Conjur::API
4
+ class << self
5
+ def host
6
+ ENV['CONJUR_LAYER_URL'] || Conjur::Core::API.host
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ module Conjur
14
+ class API
15
+ include StandardMethods
16
+ end
17
+ end
18
+
19
+ require 'conjur/api/layers'
@@ -0,0 +1,34 @@
1
+ module Conjur
2
+ class Layer < RestClient::Resource
3
+ include ActsAsAsset
4
+ include ActsAsRole
5
+
6
+ def add_host(hostid)
7
+ log do |logger|
8
+ logger << "Adding host #{hostid} to layer #{id}"
9
+ end
10
+ invalidate do
11
+ RestClient::Resource.new(self['hosts'].url, options).post(hostid: hostid)
12
+ end
13
+ end
14
+
15
+ def remove_host(hostid)
16
+ log do |logger|
17
+ logger << "Removing host #{hostid} from layer #{id}"
18
+ end
19
+ invalidate do
20
+ RestClient::Resource.new(self["hosts/#{fully_escape hostid}"].url, options).delete
21
+ end
22
+ end
23
+
24
+ def hosts
25
+ self.attributes['hosts'].collect do |id|
26
+ Conjur::Host.new(Conjur::Dep::API.host, options)["hosts/#{fully_escape id}"]
27
+ end
28
+ end
29
+
30
+ def environment
31
+ Conjur::Environment.new(Conjur::Env::API.host, options)["environments"][fully_escape attributes['environmentid']]
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,265 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: conjur-asset-layer-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Gilpin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: conjur-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: conjur-asset-environment-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: authable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails-api
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: talentbox-sequel-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pg_random_id
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sequel-attribute_callbacks
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: cucumber-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: spork
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: webmock
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: json_spec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: ci_reporter
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ description:
224
+ email:
225
+ - kgilpin@gmail.com
226
+ executables: []
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - .gitignore
231
+ - MIT-LICENSE
232
+ - README.rdoc
233
+ - Rakefile
234
+ - conjur-asset-layer.gemspec
235
+ - integration/generate_assets.sh
236
+ - lib/conjur-asset-layer-version.rb
237
+ - lib/conjur-asset-layer.rb
238
+ - lib/conjur/api/layers.rb
239
+ - lib/conjur/command/layers.rb
240
+ - lib/conjur/layer-api.rb
241
+ - lib/conjur/layer.rb
242
+ homepage: http://conjur.net
243
+ licenses: []
244
+ metadata: {}
245
+ post_install_message:
246
+ rdoc_options: []
247
+ require_paths:
248
+ - lib
249
+ required_ruby_version: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ required_rubygems_version: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - '>='
257
+ - !ruby/object:Gem::Version
258
+ version: '0'
259
+ requirements: []
260
+ rubyforge_project:
261
+ rubygems_version: 2.0.3
262
+ signing_key:
263
+ specification_version: 4
264
+ summary: Conjur asset plugin for a deployment layer.
265
+ test_files: []