conjur-cli 5.6.6 → 6.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +5 -5
  2. data/.dockerignore +1 -1
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +1 -1
  5. data/APPLIANCE_VERSION +1 -1
  6. data/CHANGELOG.md +3 -42
  7. data/Gemfile +4 -7
  8. data/Humanfile.md +31 -0
  9. data/Jenkinsfile +34 -63
  10. data/README.md +41 -55
  11. data/Rakefile +5 -1
  12. data/bin/conjur +0 -2
  13. data/build-deb.sh +1 -3
  14. data/ci/cli-test.sh +6 -0
  15. data/ci/package.sh +3 -1
  16. data/ci/publish.sh +2 -2
  17. data/ci/secrets/publish.yml +2 -2
  18. data/ci/wait_for_server.sh +10 -0
  19. data/conjur-cli.gemspec +7 -7
  20. data/dev/docker-compose.yml +24 -0
  21. data/dev/start.sh +15 -0
  22. data/dev/stop.sh +5 -0
  23. data/docker-compose.yml +30 -0
  24. data/features/authentication/authenticate.feature +34 -0
  25. data/features/authentication/login.feature +13 -0
  26. data/features/authentication/logout.feature +15 -0
  27. data/{acceptance-features → features}/authentication/whoami.feature +0 -0
  28. data/features/authorization/resource/annotate.feature +22 -0
  29. data/features/authorization/resource/check.feature +47 -0
  30. data/{acceptance-features → features}/authorization/resource/exists.feature +18 -6
  31. data/features/authorization/resource/permitted_roles.feature +35 -0
  32. data/features/authorization/resource/show.feature +34 -0
  33. data/features/authorization/role/exists.feature +28 -0
  34. data/features/authorization/role/members.feature +45 -0
  35. data/features/authorization/role/memberships.feature +43 -0
  36. data/features/conjurenv/check.feature +34 -0
  37. data/features/conjurenv/run.feature +15 -0
  38. data/{acceptance-features → features}/conjurenv/template.feature +8 -3
  39. data/{acceptance-features → features}/directory/user/update_password.feature +8 -2
  40. data/{acceptance-features → features}/directory/variable/value.feature +9 -5
  41. data/{acceptance-features → features}/directory/variable/values-add.feature +8 -3
  42. data/features/hostfactory/tokens.feature +22 -0
  43. data/features/pubkeys/show.feature +18 -0
  44. data/features/step_definitions/authn_steps.rb +22 -0
  45. data/features/step_definitions/cli_steps.rb +28 -0
  46. data/features/step_definitions/file_steps.rb +12 -0
  47. data/features/step_definitions/flow_control_steps.rb +7 -0
  48. data/features/step_definitions/graph_steps.rb +4 -3
  49. data/{acceptance-features → features}/step_definitions/http_steps.rb +0 -0
  50. data/features/step_definitions/overrides.rb +9 -0
  51. data/features/step_definitions/policy_steps.rb +11 -0
  52. data/{acceptance-features → features}/step_definitions/trusted_proxy_steps.rb +0 -0
  53. data/features/support/blank.yml +1 -0
  54. data/features/support/env.rb +21 -7
  55. data/features/support/hooks.rb +31 -116
  56. data/features/support/world.rb +16 -76
  57. data/jenkins.sh +33 -0
  58. data/lib/conjur/authenticator.rb +83 -0
  59. data/lib/conjur/authn.rb +5 -20
  60. data/lib/conjur/cli.rb +13 -6
  61. data/lib/conjur/command.rb +30 -350
  62. data/lib/conjur/command/authn.rb +23 -15
  63. data/lib/conjur/command/host_factories.rb +2 -74
  64. data/lib/conjur/command/hosts.rb +6 -113
  65. data/lib/conjur/command/init.rb +20 -35
  66. data/lib/conjur/command/{secrets.rb → policies.rb} +33 -22
  67. data/lib/conjur/command/pubkeys.rb +3 -63
  68. data/lib/conjur/command/resources.rb +45 -162
  69. data/lib/conjur/command/roles.rb +11 -181
  70. data/lib/conjur/command/rspec/helpers.rb +0 -1
  71. data/lib/conjur/command/rspec/mock_services.rb +4 -4
  72. data/lib/conjur/command/users.rb +2 -159
  73. data/lib/conjur/command/variables.rb +5 -218
  74. data/lib/conjur/complete.rb +2 -2
  75. data/lib/conjur/config.rb +1 -11
  76. data/lib/conjur/conjurenv.rb +12 -9
  77. data/lib/conjur/identifier_manipulation.rb +3 -5
  78. data/lib/conjur/version.rb +2 -2
  79. data/{publish-rubygem.sh → publish.sh} +0 -4
  80. data/spec/authn_spec.rb +4 -0
  81. data/spec/command/hosts_spec.rb +2 -69
  82. data/spec/command/init_spec.rb +16 -11
  83. data/spec/command/pubkeys_spec.rb +1 -46
  84. data/spec/command/resources_spec.rb +21 -170
  85. data/spec/command/roles_spec.rb +5 -181
  86. data/spec/command/users_spec.rb +3 -79
  87. data/spec/command_spec.rb +1 -20
  88. data/spec/complete_spec.rb +1 -23
  89. data/spec/config_spec.rb +1 -1
  90. data/spec/spec_helper.rb +4 -5
  91. data/test.sh +29 -25
  92. metadata +92 -212
  93. data/.githooks/pre_commit/run_specs.rb +0 -23
  94. data/Dockerfile +0 -15
  95. data/Dockerfile.fpm +0 -18
  96. data/Dockerfile.publish +0 -12
  97. data/Dockerfile.standalone +0 -33
  98. data/Dockerfile.validate-packaging +0 -9
  99. data/VERSION +0 -1
  100. data/acceptance-features/audit/audit_event_send.feature +0 -107
  101. data/acceptance-features/audit/fetch.feature +0 -16
  102. data/acceptance-features/audit/send.feature +0 -51
  103. data/acceptance-features/authentication/authenticate.feature +0 -10
  104. data/acceptance-features/authentication/login.feature +0 -12
  105. data/acceptance-features/authentication/logout.feature +0 -13
  106. data/acceptance-features/authorization/resource/annotate.feature +0 -35
  107. data/acceptance-features/authorization/resource/check.feature +0 -24
  108. data/acceptance-features/authorization/resource/create.feature +0 -21
  109. data/acceptance-features/authorization/resource/deny.feature +0 -12
  110. data/acceptance-features/authorization/resource/give.feature +0 -24
  111. data/acceptance-features/authorization/resource/permit.feature +0 -20
  112. data/acceptance-features/authorization/resource/permitted_roles.feature +0 -16
  113. data/acceptance-features/authorization/resource/show.feature +0 -28
  114. data/acceptance-features/authorization/role/create.feature +0 -13
  115. data/acceptance-features/authorization/role/exists.feature +0 -19
  116. data/acceptance-features/authorization/role/grant_to.feature +0 -21
  117. data/acceptance-features/authorization/role/graph.feature +0 -57
  118. data/acceptance-features/authorization/role/members.feature +0 -23
  119. data/acceptance-features/authorization/role/memberships.feature +0 -27
  120. data/acceptance-features/bootstrap.feature +0 -13
  121. data/acceptance-features/conjurenv/check.feature +0 -21
  122. data/acceptance-features/conjurenv/run.feature +0 -10
  123. data/acceptance-features/directory/group/create.feature +0 -20
  124. data/acceptance-features/directory/group/retire.feature +0 -54
  125. data/acceptance-features/directory/host/create.feature +0 -23
  126. data/acceptance-features/directory/host/retire.feature +0 -6
  127. data/acceptance-features/directory/hostfactory/create.feature +0 -28
  128. data/acceptance-features/directory/hostfactory/tokens.feature +0 -16
  129. data/acceptance-features/directory/layer/create.feature +0 -10
  130. data/acceptance-features/directory/layer/hosts-add.feature +0 -9
  131. data/acceptance-features/directory/layer/hosts-remove.feature +0 -10
  132. data/acceptance-features/directory/layer/retire.feature +0 -43
  133. data/acceptance-features/directory/user/create.feature +0 -23
  134. data/acceptance-features/directory/user/retire.feature +0 -6
  135. data/acceptance-features/directory/variable/create.feature +0 -14
  136. data/acceptance-features/directory/variable/retire.feature +0 -17
  137. data/acceptance-features/dsl/policy_owner.feature +0 -45
  138. data/acceptance-features/dsl/resource_owner.feature +0 -17
  139. data/acceptance-features/dsl/retire.feature +0 -15
  140. data/acceptance-features/global-privilege/elevate.feature +0 -20
  141. data/acceptance-features/global-privilege/reveal.privilege +0 -20
  142. data/acceptance-features/pubkeys/add.feature +0 -22
  143. data/acceptance-features/pubkeys/delete.feature +0 -9
  144. data/acceptance-features/pubkeys/names.feature +0 -26
  145. data/acceptance-features/pubkeys/show.feature +0 -27
  146. data/acceptance-features/step_definitions/cli_steps.rb +0 -57
  147. data/acceptance-features/step_definitions/graph_steps.rb +0 -22
  148. data/acceptance-features/step_definitions/user_steps.rb +0 -51
  149. data/acceptance-features/support/env.rb +0 -23
  150. data/acceptance-features/support/hooks.rb +0 -178
  151. data/acceptance-features/support/world.rb +0 -176
  152. data/acceptance-features/trusted_proxies.feature +0 -82
  153. data/bin/conjurize +0 -26
  154. data/bin/jsonfield +0 -70
  155. data/build-standalone +0 -6
  156. data/deprecations.sh +0 -38
  157. data/features/conjurize.feature +0 -134
  158. data/features/dsl_context.feature +0 -36
  159. data/features/dsl_host_create.feature +0 -11
  160. data/features/dsl_ownership.feature +0 -30
  161. data/features/dsl_permission.feature +0 -45
  162. data/features/dsl_resource_create.feature +0 -23
  163. data/features/dsl_role_create.feature +0 -11
  164. data/features/dsl_user_create.feature +0 -23
  165. data/features/jsonfield.feature +0 -49
  166. data/features/role_graph.feature +0 -58
  167. data/features/step_definitions/conjurize_steps.rb +0 -5
  168. data/features/step_definitions/dsl_steps.rb +0 -52
  169. data/features/support/conjur.conf +0 -6
  170. data/lib/conjur/command/assets.rb +0 -121
  171. data/lib/conjur/command/audit.rb +0 -155
  172. data/lib/conjur/command/bootstrap.rb +0 -129
  173. data/lib/conjur/command/dsl_command.rb +0 -75
  174. data/lib/conjur/command/elevate.rb +0 -76
  175. data/lib/conjur/command/field.rb +0 -45
  176. data/lib/conjur/command/groups.rb +0 -208
  177. data/lib/conjur/command/ids.rb +0 -34
  178. data/lib/conjur/command/layers.rb +0 -211
  179. data/lib/conjur/command/ldapsync.rb +0 -118
  180. data/lib/conjur/command/rspec/audit_helpers.rb +0 -68
  181. data/lib/conjur/command/rubydsl.rb +0 -93
  182. data/lib/conjur/command/script.rb +0 -48
  183. data/lib/conjur/command/server.rb +0 -67
  184. data/lib/conjur/conjurize.rb +0 -71
  185. data/lib/conjur/conjurize/script.rb +0 -150
  186. data/lib/conjur/dsl/runner.rb +0 -273
  187. data/publish-deb.sh +0 -6
  188. data/push-image +0 -29
  189. data/spec/command/assets_spec.rb +0 -115
  190. data/spec/command/audit_spec.rb +0 -376
  191. data/spec/command/elevate_spec.rb +0 -28
  192. data/spec/command/env_spec.rb +0 -168
  193. data/spec/command/groups_spec.rb +0 -77
  194. data/spec/command/host_factories_spec.rb +0 -38
  195. data/spec/command/layers_spec.rb +0 -35
  196. data/spec/command/ldapsync_spec.rb +0 -28
  197. data/spec/command/rubydsl_spec.rb +0 -63
  198. data/spec/command/variable_expiration_spec.rb +0 -164
  199. data/spec/command/variables_spec.rb +0 -192
  200. data/spec/conjurize/script_spec.rb +0 -62
  201. data/spec/conjurize_spec.rb +0 -70
  202. data/spec/dsl/runner_spec.rb +0 -93
  203. data/spec/env_spec.rb +0 -214
@@ -1,129 +0,0 @@
1
- #
2
- # Copyright (C) 2014-2016 Conjur Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
-
22
- class Conjur::Command::Bootstrap < Conjur::Command
23
- desc "Create initial users, groups, permissions, and service identities."
24
- long_desc %Q(When you launch a new Conjur master server, it contains only one login: the "admin" user.
25
- The bootstrap command will finish the setup of a new Conjur system by creating other essential records.
26
-
27
- Actions performed by "bootstrap" include:
28
-
29
- * Creation of a group called "security_admin".
30
-
31
- * Giving the "security_admin" the power to manage public keys.
32
-
33
- * Creation of a user called "attic", which will be the owner of retired records.
34
-
35
- * Create system identities for use services such as pubkeys, rotator, and ldap-sync.
36
-
37
- * (optional) Create a new user who will be made a member and admin of the "security_admin" group.
38
-
39
- * (optional) If a new user was created, login as that user.
40
-
41
- The Bootstrap command can be extended to perform additional actions by CLI plugins. The plugin just
42
- needs to define a new class in Conjur::Bootstrap::Command. Its "perform" method will be run automatically.
43
- )
44
-
45
- class BootstrapListener
46
- def echo msg
47
- $stderr.puts msg
48
- end
49
- end
50
-
51
- class << self
52
- def quiet? options
53
- !$stdin.tty? || options[:quiet]
54
- end
55
- end
56
-
57
- Conjur::CLI.command :bootstrap do |c|
58
- c.desc "Print out all the commands to stderr as they run."
59
- c.default_value true
60
- c.switch [:v, :verbose]
61
-
62
- c.desc "Don't prompt for any user input, even if there's a TTY."
63
- c.long_desc %Q(By default, 'bootstrap' may issue prompts on the TTY. For example, it will prompt you
64
- to login if you aren't currently logged in as any user. It will also ask you if you want to create a new
65
- 'security_admin' user. This switch can be used to disable all such prompts, making it safe to run
66
- 'bootstrap' even when requests for user input cannot be handled. Prompts are also disabled if STDIN
67
- is not a tty.)
68
- c.default_value false
69
- c.switch [:q, :quiet]
70
-
71
- c.action do |global_options,options,args|
72
- require 'highline/import'
73
-
74
- # Ensure there's a logged in user
75
- connect_options = {}
76
- connect_options[:noask] = true if quiet?(options)
77
- Conjur::Authn.connect nil, connect_options
78
-
79
- unless api.global_privilege_permitted?('elevate')
80
- $stderr.puts [
81
- "You must have 'elevate' privilege to bootstrap Conjur.",
82
- "If are performing a first-time bootstrap of Conjur, you should login as the 'admin' user",
83
- "using the admin password you selected when you ran 'evoke configure master'.",
84
- "",
85
- "If you have run 'conjur bootstrap' before, using CLI version 4.30.0 or later, the 'elevate'",
86
- "privilege is available to all members of the security_admin group."
87
- ].join("\n")
88
- exit_now! "Insufficient privileges to run 'bootstrap'."
89
- end
90
-
91
- saved_log = Conjur.log
92
- Conjur.log = $stderr if options[:verbose]
93
-
94
- api = self.api.with_privilege('elevate')
95
- self.api = api
96
-
97
- api.bootstrap BootstrapListener.new
98
-
99
- unless quiet?(options)
100
- security_admin = api.group('security_admin')
101
- security_administrators = security_admin.role.members.select{|m| m.member.roleid.split(':')[1..-1] != [ 'user', 'admin'] }
102
- $stderr.puts "Current 'security_admin' members are : #{security_administrators.map{|m| m.member.roleid.split(':', 3)[1..-1].join(':')}.sort.join(', ')}" unless security_administrators.blank?
103
- created_user = nil
104
- if security_administrators.empty? || agree("Create a new security_admin? (answer 'y' or 'yes'):")
105
- username = ask("Enter #{security_administrators.empty? ? 'your' : 'the'} username:")
106
- password = prompt_for_password
107
- begin
108
- # Don't echo the new admin user's password
109
- Conjur.log = nil
110
- $stderr.puts "Creating user '#{username}'"
111
- created_user = user = api.create_user(username, password: password)
112
- ensure
113
- Conjur.log = saved_log
114
- end
115
- Conjur::API.new_from_key(user.login, password).user(user.login).resource.give_to security_admin
116
- $stderr.puts "User created"
117
- $stderr.puts "Making '#{username}' a member and admin of group 'security_admin'"
118
- security_admin.add_member user, admin_option: true
119
- $stderr.puts "Adminship granted"
120
- end
121
-
122
- if created_user && agree("Login as user '#{created_user.login}'? (answer 'y' or 'yes'):")
123
- Conjur::Authn.fetch_credentials(username: created_user.login, password: created_user.api_key)
124
- $stderr.puts "Logged in as '#{created_user.login}'"
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -1,75 +0,0 @@
1
- #
2
- # Copyright (C) 2014 Conjur Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
-
22
- class Conjur::DSLCommand < Conjur::Command
23
- class << self
24
- def run_script(args, options, &block)
25
- Conjur.log = "stderr"
26
-
27
- filename = nil
28
- script = if script = args.pop
29
- filename = script
30
- script = if File.exists?(script)
31
- File.read(script)
32
- else
33
- require 'open-uri'
34
- uri = URI.parse(script)
35
- raise "Unable to read this kind of URL : #{script}" unless uri.respond_to?(:read)
36
- begin
37
- uri.read
38
- rescue OpenURI::HTTPError
39
- raise "Unable to read URI #{script} : #{$!.message}"
40
- end
41
- end
42
- else
43
- STDIN.read
44
- end
45
-
46
- require 'conjur/dsl/runner'
47
- runner = Conjur::DSL::Runner.new(script, filename)
48
- runner.owner = options[:ownerid] if options[:ownerid]
49
-
50
- if context = options[:context]
51
- runner.context = begin
52
- JSON.parse(File.read(context))
53
- rescue Errno::ENOENT
54
- {}
55
- end
56
- end
57
-
58
- if block_given?
59
- block.call(runner) do
60
- runner.execute
61
- end
62
- else
63
- runner.execute
64
- end
65
-
66
- if context
67
- File.write(context, JSON.pretty_generate(runner.context))
68
- File.chmod(0600, context)
69
- end
70
-
71
- puts JSON.pretty_generate(runner.context)
72
- end
73
- end
74
-
75
- end
@@ -1,76 +0,0 @@
1
- #
2
- # Copyright (C) 2015 Conjur Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
-
22
- # Implement privileged modes such as 'elevate' and 'reveal'
23
- class Conjur::Command::Elevate < Conjur::DSLCommand
24
-
25
- def self.subcommand args
26
- code = Conjur::CLI.run args
27
- raise GLI::CustomExit.new("Subcommand failed", code) unless code == 0
28
- end
29
-
30
- desc "Run a sub-command with elevated privileges"
31
- long_desc <<-DESC
32
- If you are allowed to do this by the Conjur server, all server-side permission checks will be bypassed and any
33
- action will be allowed.
34
-
35
- To be able to run this command, you must have the 'elevate' privilege on the resource '!:!:conjur'.
36
-
37
- EXAMPLE
38
-
39
- Force retirement of a user:
40
-
41
- $ conjur elevate user retire alice
42
- DESC
43
- command :elevate do |c|
44
- c.action do |global_options,options,args|
45
- exit_now! "Subcommand is required" if args.empty?
46
-
47
- Conjur::Command.api = api.with_privilege "elevate"
48
- subcommand args
49
- end
50
- end
51
-
52
- desc "Run a sub-command in 'reveal' mode"
53
- long_desc <<-DESC
54
- If you are allowed to do this by the Conjur server, you can inspect all data in the Conjur
55
- authorization service. For example, you can list and search for all resources, regardless of
56
- your ownership and privileges. You can also show details on any resource, and you can perform
57
- permission checks on any resource.
58
-
59
- To be able to run this command, you must have the 'reveal' privilege on the resource '!:!:conjur'.
60
-
61
- EXAMPLE
62
-
63
- List all groups:
64
-
65
- $ conjur reveal group list -i
66
-
67
- DESC
68
- command :reveal do |c|
69
- c.action do |global_options,options,args|
70
- exit_now! "Subcommand is required" if args.empty?
71
-
72
- Conjur::Command.api = api.with_privilege "reveal"
73
- subcommand args
74
- end
75
- end
76
- end
@@ -1,45 +0,0 @@
1
- #
2
- # Copyright (C) 2013 Conjur Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
- class Conjur::Command::Field < Conjur::Command
22
- self.prefix = :field
23
-
24
- desc "(Deprecated. See standalone jsonfield command instead.)"
25
- command :select do |c|
26
- hide_docs(c)
27
-
28
- c.action do |global_options,options,args|
29
- pattern = require_arg(args, 'pattern')
30
- value = args.shift || STDIN.read
31
-
32
- warn "field:select is deprecated. Please use jsonfield command instead."
33
- require 'json'
34
- json = JSON.parse(value)
35
- class << json
36
- def get_binding
37
- record = self
38
-
39
- binding
40
- end
41
- end
42
- puts json.get_binding.eval(pattern)
43
- end
44
- end
45
- end
@@ -1,208 +0,0 @@
1
- #
2
- # Copyright (C) 2013 Conjur Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
-
22
- class Conjur::Command::Groups < Conjur::Command
23
- def self.assume_user_kind(role)
24
- if role.split(':').length == 1
25
- role = [ "user", role ].join(':')
26
- end
27
- role
28
- end
29
-
30
- desc "Manage groups"
31
- command :group do |group|
32
- group.desc "Create a new group [DEPRECATED]"
33
- group.command :create do |c|
34
- c.desc "GID number to be associated with the group (optional)"
35
- c.flag [:gidnumber]
36
-
37
- acting_as_option(c)
38
- interactive_option c
39
-
40
- c.action do |global_options,options,args|
41
- notify_deprecated
42
-
43
- id = args.shift
44
-
45
- interactive = options[:interactive] || id.blank?
46
-
47
- groupid = options[:ownerid]
48
- gidnumber = options[:gidnumber]
49
-
50
- if interactive
51
- id ||= prompt_for_id :group
52
-
53
- groupid ||= prompt_for_group
54
- gidnumber ||= prompt_for_gidnumber
55
-
56
- prompt_to_confirm :group, {
57
- "Id" => id,
58
- "Owner" => groupid,
59
- "Gidnumber" => gidnumber
60
- }
61
- end
62
-
63
- group_options = { }
64
- group_options[:ownerid] = groupid if groupid
65
- group_options[:gidnumber] = gidnumber.to_i unless gidnumber.blank?
66
-
67
- group = api.create_group(id, group_options)
68
- display(group, options)
69
- end
70
- end
71
-
72
- group.desc "List groups"
73
- group.command :list do |c|
74
- command_options_for_list c
75
-
76
- c.action do |global_options, options, args|
77
- command_impl_for_list global_options, options.merge(kind: "group"), args
78
- end
79
- end
80
-
81
- group.desc "Show a group"
82
- group.arg_name "GROUP"
83
- group.command :show do |c|
84
- c.action do |global_options,options,args|
85
- id = require_arg(args, 'GROUP')
86
- display(api.group(id), options)
87
- end
88
- end
89
-
90
- group.desc "Update group's attributes (eg. gidnumber) [DEPRECATED]"
91
- group.arg_name "GROUP"
92
- group.command :update do |c|
93
- c.desc "GID number to be associated with the group"
94
- c.flag [:gidnumber]
95
- c.action do |global_options, options, args|
96
- notify_deprecated
97
-
98
- id = require_arg(args, 'GROUP')
99
-
100
- options[:gidnumber] = Integer(options[:gidnumber])
101
- api.group(id).update(options)
102
-
103
- puts "GID set"
104
- end
105
- end
106
-
107
- group.desc "Find groups by GID"
108
- group.arg_name "gid"
109
- group.command :gidsearch do |c|
110
- c.action do |global_options, options, args|
111
- gidnumber = Integer require_arg args, 'gid'
112
- display api.find_groups(gidnumber: gidnumber)
113
- end
114
- end
115
-
116
- group.desc "Decommission a group [DEPRECATED]"
117
- group.arg_name "GROUP"
118
- group.command :retire do |c|
119
- retire_options c
120
-
121
- c.action do |global_options,options,args|
122
- notify_deprecated
123
-
124
- id = require_arg(args, 'GROUP')
125
-
126
- group = api.group(id)
127
-
128
- validate_retire_privileges group, options
129
-
130
- retire_resource group
131
- retire_role group
132
- give_away_resource group, options
133
-
134
- puts "Group retired"
135
- end
136
- end
137
-
138
- group.desc "Show and manage group members"
139
- group.command :members do |members|
140
-
141
- members.desc "Lists all direct members of the group. The membership list is not recursively expanded."
142
- members.arg_name "GROUP"
143
- members.command :list do |c|
144
- c.desc "Verbose output"
145
- c.switch [:V,:verbose]
146
- c.action do |global_options,options,args|
147
- group = require_arg(args, 'GROUP')
148
- display_members api.group(group).role.members, :member, options
149
- end
150
- end
151
-
152
- members.desc "Add a new group member [DEPRECATED]"
153
- members.arg_name "GROUP USER"
154
- members.command :add do |c|
155
- c.desc "Also grant the admin option"
156
- c.switch [:a, :admin]
157
-
158
- # perhaps this belongs to member:remove, but then either
159
- # it would be possible to grant membership with member:revoke,
160
- # or we would need two round-trips to authz
161
- c.desc "Revoke the grant option if it's granted"
162
- c.switch [:r, :'revoke-admin']
163
-
164
- c.action do |global_options,options,args|
165
- notify_deprecated
166
-
167
- group = require_arg(args, 'GROUP')
168
- member = require_arg(args, 'USER')
169
- member = assume_user_kind(member)
170
-
171
- group = api.group(group)
172
- opts = nil
173
- message = "Membership granted"
174
- if options[:admin] then
175
- opts = { admin_option: true }
176
- message = "Adminship granted"
177
- elsif options[:'revoke-admin'] then
178
- opts = { admin_option: false }
179
- message = "Adminship revoked"
180
- end
181
-
182
- group.add_member member, opts
183
- puts message
184
- end
185
- end
186
-
187
- members.desc "Remove a group member [DEPRECATED]"
188
- members.arg_name "GROUP USER"
189
- members.command :remove do |c|
190
- c.action do |global_options,options,args|
191
- notify_deprecated
192
-
193
- group = require_arg(args, 'GROUP')
194
- member = require_arg(args, 'USER')
195
- member = assume_user_kind(member)
196
-
197
- api.group(group).remove_member member
198
- puts "Membership revoked"
199
- end
200
- end
201
-
202
- end
203
- end
204
-
205
- def self.prompt_for_gidnumber
206
- prompt_for_idnumber "gid number"
207
- end
208
- end