conjur-cli 5.6.6 → 6.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.dockerignore +1 -1
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/APPLIANCE_VERSION +1 -1
- data/CHANGELOG.md +3 -42
- data/Gemfile +4 -7
- data/Humanfile.md +31 -0
- data/Jenkinsfile +34 -63
- data/README.md +41 -55
- data/Rakefile +5 -1
- data/bin/conjur +0 -2
- data/build-deb.sh +1 -3
- data/ci/cli-test.sh +6 -0
- data/ci/package.sh +3 -1
- data/ci/publish.sh +2 -2
- data/ci/secrets/publish.yml +2 -2
- data/ci/wait_for_server.sh +10 -0
- data/conjur-cli.gemspec +7 -7
- data/dev/docker-compose.yml +24 -0
- data/dev/start.sh +15 -0
- data/dev/stop.sh +5 -0
- data/docker-compose.yml +30 -0
- data/features/authentication/authenticate.feature +34 -0
- data/features/authentication/login.feature +13 -0
- data/features/authentication/logout.feature +15 -0
- data/{acceptance-features → features}/authentication/whoami.feature +0 -0
- data/features/authorization/resource/annotate.feature +22 -0
- data/features/authorization/resource/check.feature +47 -0
- data/{acceptance-features → features}/authorization/resource/exists.feature +18 -6
- data/features/authorization/resource/permitted_roles.feature +35 -0
- data/features/authorization/resource/show.feature +34 -0
- data/features/authorization/role/exists.feature +28 -0
- data/features/authorization/role/members.feature +45 -0
- data/features/authorization/role/memberships.feature +43 -0
- data/features/conjurenv/check.feature +34 -0
- data/features/conjurenv/run.feature +15 -0
- data/{acceptance-features → features}/conjurenv/template.feature +8 -3
- data/{acceptance-features → features}/directory/user/update_password.feature +8 -2
- data/{acceptance-features → features}/directory/variable/value.feature +9 -5
- data/{acceptance-features → features}/directory/variable/values-add.feature +8 -3
- data/features/hostfactory/tokens.feature +22 -0
- data/features/pubkeys/show.feature +18 -0
- data/features/step_definitions/authn_steps.rb +22 -0
- data/features/step_definitions/cli_steps.rb +28 -0
- data/features/step_definitions/file_steps.rb +12 -0
- data/features/step_definitions/flow_control_steps.rb +7 -0
- data/features/step_definitions/graph_steps.rb +4 -3
- data/{acceptance-features → features}/step_definitions/http_steps.rb +0 -0
- data/features/step_definitions/overrides.rb +9 -0
- data/features/step_definitions/policy_steps.rb +11 -0
- data/{acceptance-features → features}/step_definitions/trusted_proxy_steps.rb +0 -0
- data/features/support/blank.yml +1 -0
- data/features/support/env.rb +21 -7
- data/features/support/hooks.rb +31 -116
- data/features/support/world.rb +16 -76
- data/jenkins.sh +33 -0
- data/lib/conjur/authenticator.rb +83 -0
- data/lib/conjur/authn.rb +5 -20
- data/lib/conjur/cli.rb +13 -6
- data/lib/conjur/command.rb +30 -350
- data/lib/conjur/command/authn.rb +23 -15
- data/lib/conjur/command/host_factories.rb +2 -74
- data/lib/conjur/command/hosts.rb +6 -113
- data/lib/conjur/command/init.rb +20 -35
- data/lib/conjur/command/{secrets.rb → policies.rb} +33 -22
- data/lib/conjur/command/pubkeys.rb +3 -63
- data/lib/conjur/command/resources.rb +45 -162
- data/lib/conjur/command/roles.rb +11 -181
- data/lib/conjur/command/rspec/helpers.rb +0 -1
- data/lib/conjur/command/rspec/mock_services.rb +4 -4
- data/lib/conjur/command/users.rb +2 -159
- data/lib/conjur/command/variables.rb +5 -218
- data/lib/conjur/complete.rb +2 -2
- data/lib/conjur/config.rb +1 -11
- data/lib/conjur/conjurenv.rb +12 -9
- data/lib/conjur/identifier_manipulation.rb +3 -5
- data/lib/conjur/version.rb +2 -2
- data/{publish-rubygem.sh → publish.sh} +0 -4
- data/spec/authn_spec.rb +4 -0
- data/spec/command/hosts_spec.rb +2 -69
- data/spec/command/init_spec.rb +16 -11
- data/spec/command/pubkeys_spec.rb +1 -46
- data/spec/command/resources_spec.rb +21 -170
- data/spec/command/roles_spec.rb +5 -181
- data/spec/command/users_spec.rb +3 -79
- data/spec/command_spec.rb +1 -20
- data/spec/complete_spec.rb +1 -23
- data/spec/config_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -5
- data/test.sh +29 -25
- metadata +92 -212
- data/.githooks/pre_commit/run_specs.rb +0 -23
- data/Dockerfile +0 -15
- data/Dockerfile.fpm +0 -18
- data/Dockerfile.publish +0 -12
- data/Dockerfile.standalone +0 -33
- data/Dockerfile.validate-packaging +0 -9
- data/VERSION +0 -1
- data/acceptance-features/audit/audit_event_send.feature +0 -107
- data/acceptance-features/audit/fetch.feature +0 -16
- data/acceptance-features/audit/send.feature +0 -51
- data/acceptance-features/authentication/authenticate.feature +0 -10
- data/acceptance-features/authentication/login.feature +0 -12
- data/acceptance-features/authentication/logout.feature +0 -13
- data/acceptance-features/authorization/resource/annotate.feature +0 -35
- data/acceptance-features/authorization/resource/check.feature +0 -24
- data/acceptance-features/authorization/resource/create.feature +0 -21
- data/acceptance-features/authorization/resource/deny.feature +0 -12
- data/acceptance-features/authorization/resource/give.feature +0 -24
- data/acceptance-features/authorization/resource/permit.feature +0 -20
- data/acceptance-features/authorization/resource/permitted_roles.feature +0 -16
- data/acceptance-features/authorization/resource/show.feature +0 -28
- data/acceptance-features/authorization/role/create.feature +0 -13
- data/acceptance-features/authorization/role/exists.feature +0 -19
- data/acceptance-features/authorization/role/grant_to.feature +0 -21
- data/acceptance-features/authorization/role/graph.feature +0 -57
- data/acceptance-features/authorization/role/members.feature +0 -23
- data/acceptance-features/authorization/role/memberships.feature +0 -27
- data/acceptance-features/bootstrap.feature +0 -13
- data/acceptance-features/conjurenv/check.feature +0 -21
- data/acceptance-features/conjurenv/run.feature +0 -10
- data/acceptance-features/directory/group/create.feature +0 -20
- data/acceptance-features/directory/group/retire.feature +0 -54
- data/acceptance-features/directory/host/create.feature +0 -23
- data/acceptance-features/directory/host/retire.feature +0 -6
- data/acceptance-features/directory/hostfactory/create.feature +0 -28
- data/acceptance-features/directory/hostfactory/tokens.feature +0 -16
- data/acceptance-features/directory/layer/create.feature +0 -10
- data/acceptance-features/directory/layer/hosts-add.feature +0 -9
- data/acceptance-features/directory/layer/hosts-remove.feature +0 -10
- data/acceptance-features/directory/layer/retire.feature +0 -43
- data/acceptance-features/directory/user/create.feature +0 -23
- data/acceptance-features/directory/user/retire.feature +0 -6
- data/acceptance-features/directory/variable/create.feature +0 -14
- data/acceptance-features/directory/variable/retire.feature +0 -17
- data/acceptance-features/dsl/policy_owner.feature +0 -45
- data/acceptance-features/dsl/resource_owner.feature +0 -17
- data/acceptance-features/dsl/retire.feature +0 -15
- data/acceptance-features/global-privilege/elevate.feature +0 -20
- data/acceptance-features/global-privilege/reveal.privilege +0 -20
- data/acceptance-features/pubkeys/add.feature +0 -22
- data/acceptance-features/pubkeys/delete.feature +0 -9
- data/acceptance-features/pubkeys/names.feature +0 -26
- data/acceptance-features/pubkeys/show.feature +0 -27
- data/acceptance-features/step_definitions/cli_steps.rb +0 -57
- data/acceptance-features/step_definitions/graph_steps.rb +0 -22
- data/acceptance-features/step_definitions/user_steps.rb +0 -51
- data/acceptance-features/support/env.rb +0 -23
- data/acceptance-features/support/hooks.rb +0 -178
- data/acceptance-features/support/world.rb +0 -176
- data/acceptance-features/trusted_proxies.feature +0 -82
- data/bin/conjurize +0 -26
- data/bin/jsonfield +0 -70
- data/build-standalone +0 -6
- data/deprecations.sh +0 -38
- data/features/conjurize.feature +0 -134
- data/features/dsl_context.feature +0 -36
- data/features/dsl_host_create.feature +0 -11
- data/features/dsl_ownership.feature +0 -30
- data/features/dsl_permission.feature +0 -45
- data/features/dsl_resource_create.feature +0 -23
- data/features/dsl_role_create.feature +0 -11
- data/features/dsl_user_create.feature +0 -23
- data/features/jsonfield.feature +0 -49
- data/features/role_graph.feature +0 -58
- data/features/step_definitions/conjurize_steps.rb +0 -5
- data/features/step_definitions/dsl_steps.rb +0 -52
- data/features/support/conjur.conf +0 -6
- data/lib/conjur/command/assets.rb +0 -121
- data/lib/conjur/command/audit.rb +0 -155
- data/lib/conjur/command/bootstrap.rb +0 -129
- data/lib/conjur/command/dsl_command.rb +0 -75
- data/lib/conjur/command/elevate.rb +0 -76
- data/lib/conjur/command/field.rb +0 -45
- data/lib/conjur/command/groups.rb +0 -208
- data/lib/conjur/command/ids.rb +0 -34
- data/lib/conjur/command/layers.rb +0 -211
- data/lib/conjur/command/ldapsync.rb +0 -118
- data/lib/conjur/command/rspec/audit_helpers.rb +0 -68
- data/lib/conjur/command/rubydsl.rb +0 -93
- data/lib/conjur/command/script.rb +0 -48
- data/lib/conjur/command/server.rb +0 -67
- data/lib/conjur/conjurize.rb +0 -71
- data/lib/conjur/conjurize/script.rb +0 -150
- data/lib/conjur/dsl/runner.rb +0 -273
- data/publish-deb.sh +0 -6
- data/push-image +0 -29
- data/spec/command/assets_spec.rb +0 -115
- data/spec/command/audit_spec.rb +0 -376
- data/spec/command/elevate_spec.rb +0 -28
- data/spec/command/env_spec.rb +0 -168
- data/spec/command/groups_spec.rb +0 -77
- data/spec/command/host_factories_spec.rb +0 -38
- data/spec/command/layers_spec.rb +0 -35
- data/spec/command/ldapsync_spec.rb +0 -28
- data/spec/command/rubydsl_spec.rb +0 -63
- data/spec/command/variable_expiration_spec.rb +0 -164
- data/spec/command/variables_spec.rb +0 -192
- data/spec/conjurize/script_spec.rb +0 -62
- data/spec/conjurize_spec.rb +0 -70
- data/spec/dsl/runner_spec.rb +0 -93
- 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
|
data/lib/conjur/command/field.rb
DELETED
|
@@ -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
|