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
data/lib/conjur/command/authn.rb
CHANGED
|
@@ -31,10 +31,6 @@ for the username. Password can be provided as -p, --password, or the command wil
|
|
|
31
31
|
On successful login, the password is exchanged for the API key, which is cached in the operating system user's
|
|
32
32
|
.netrc file. Subsequent "conjur" commands will authenticate with the cached login name and API key. To switch users,
|
|
33
33
|
login again using the new user credentials. To erase credentials, use the 'authn logout' command.
|
|
34
|
-
|
|
35
|
-
If specified, the CAS server URL should be in the form https://<hostname>/v1.
|
|
36
|
-
It should be running the CAS RESTful services at the /v1 path
|
|
37
|
-
(or other path as specified by this argument).
|
|
38
34
|
DESC
|
|
39
35
|
authn.command :login do |c|
|
|
40
36
|
c.arg_name 'username'
|
|
@@ -43,10 +39,6 @@ It should be running the CAS RESTful services at the /v1 path
|
|
|
43
39
|
c.arg_name 'password'
|
|
44
40
|
c.flag [:p,:password]
|
|
45
41
|
|
|
46
|
-
c.arg_name 'CAS server'
|
|
47
|
-
c.desc 'Specifies a CAS server URL to use for login'
|
|
48
|
-
c.flag [:"cas-server"]
|
|
49
|
-
|
|
50
42
|
c.action do |global_options,options,args|
|
|
51
43
|
if options[:username].blank? && !args.empty?
|
|
52
44
|
options[:username] = args.pop
|
|
@@ -60,16 +52,32 @@ It should be running the CAS RESTful services at the /v1 path
|
|
|
60
52
|
|
|
61
53
|
authn.desc "Obtains an authentication token using the current logged-in user"
|
|
62
54
|
authn.command :authenticate do |c|
|
|
63
|
-
c.arg_name 'header'
|
|
64
55
|
c.desc "Base64 encode the result and format as an HTTP Authorization header"
|
|
65
56
|
c.switch [:H,:header]
|
|
66
57
|
|
|
58
|
+
c.arg_name 'filename'
|
|
59
|
+
c.desc 'Keeps a fresh access token in the indicated file. With this argument, the command runs forever.'
|
|
60
|
+
c.flag [ :f, :filename ]
|
|
61
|
+
|
|
67
62
|
c.action do |global_options,options,args|
|
|
68
|
-
token
|
|
69
|
-
if
|
|
70
|
-
|
|
63
|
+
# Authenticate will try and parse the token file to read the expiration time.
|
|
64
|
+
# It only knows how to do that if the token file contains a JSON access token.
|
|
65
|
+
raise "--header option is not supported with --filename option" if options[:header] && options[:filename]
|
|
66
|
+
|
|
67
|
+
authenticate = lambda {
|
|
68
|
+
Conjur::Authn.authenticate
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if filename = options[:filename]
|
|
72
|
+
Conjur::Authenticator.run authenticate: authenticate, filename: filename
|
|
71
73
|
else
|
|
72
|
-
|
|
74
|
+
formatter = if options[:header]
|
|
75
|
+
lambda {|token| "Authorization: Token token=\"#{Base64.strict_encode64(JSON.generate token)}\"" }
|
|
76
|
+
else
|
|
77
|
+
lambda {|token| JSON.pretty_generate token }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
puts formatter.call(authenticate.call)
|
|
73
81
|
end
|
|
74
82
|
end
|
|
75
83
|
end
|
|
@@ -88,11 +96,11 @@ It should be running the CAS RESTful services at the /v1 path
|
|
|
88
96
|
c.action do
|
|
89
97
|
begin
|
|
90
98
|
creds = Conjur::Authn.get_credentials(noask: true)
|
|
91
|
-
puts({account: Conjur
|
|
99
|
+
puts({account: Conjur.configuration.account, username: creds[0]}.to_json)
|
|
92
100
|
rescue Conjur::Authn::NoCredentialsError
|
|
93
101
|
exit_now! 'Not logged in.', -1
|
|
94
102
|
end
|
|
95
103
|
end
|
|
96
104
|
end
|
|
97
105
|
end
|
|
98
|
-
end
|
|
106
|
+
end
|
|
@@ -23,66 +23,6 @@ class Conjur::Command::HostFactories < Conjur::Command
|
|
|
23
23
|
desc "Manage host factories"
|
|
24
24
|
|
|
25
25
|
command :hostfactory do |hf|
|
|
26
|
-
hf.desc "Create a new host factory [DEPRECATED]"
|
|
27
|
-
hf.arg_name "id"
|
|
28
|
-
hf.command :create do |c|
|
|
29
|
-
acting_as_option(c)
|
|
30
|
-
|
|
31
|
-
c.arg_name "layer"
|
|
32
|
-
c.desc "A space-delimited list of layers to which new hosts will belong"
|
|
33
|
-
c.flag [:l, :layer]
|
|
34
|
-
|
|
35
|
-
c.action do |global_options,options,args|
|
|
36
|
-
notify_deprecated
|
|
37
|
-
|
|
38
|
-
id = require_arg(args, 'hostfactory')
|
|
39
|
-
|
|
40
|
-
unless options[:ownerid]
|
|
41
|
-
exit_now! "Use --as-group or --as-role to indicate the host factory role"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
owner_role = api.role(options[:ownerid])
|
|
45
|
-
|
|
46
|
-
layers = (options[:layer] || "").split(/\s/)
|
|
47
|
-
exit_now! "Provide at least one layer" unless layers.count > 0
|
|
48
|
-
|
|
49
|
-
unless has_admin?(current_role, owner_role)
|
|
50
|
-
exit_now! "#{owner_role.id} must be an admin of role '#{owner_role.roleid}' to create a host factory for it"
|
|
51
|
-
end
|
|
52
|
-
layers.each do |layerid|
|
|
53
|
-
layer = api.layer(layerid)
|
|
54
|
-
exit_now! "Layer '#{layerid}' does not exist" unless layer.exists?
|
|
55
|
-
unless has_admin?(owner_role, layer.role)
|
|
56
|
-
exit_now! "#{owner_role.id} must be an admin of layer '#{layerid}' to create a host factory for it"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
command_options = options.dup
|
|
61
|
-
command_options[:layers] = layers
|
|
62
|
-
command_options[:roleid] = options[:ownerid]
|
|
63
|
-
|
|
64
|
-
host_factory = api.create_host_factory id, command_options
|
|
65
|
-
display host_factory
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
hf.desc "Show a host factory"
|
|
70
|
-
hf.arg_name "id"
|
|
71
|
-
hf.command :show do |c|
|
|
72
|
-
c.action do |global_options,options,args|
|
|
73
|
-
id = require_arg(args, 'id')
|
|
74
|
-
display(api.host_factory(id), options)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
hf.desc "List host factories"
|
|
79
|
-
hf.command :list do |c|
|
|
80
|
-
command_options_for_list c
|
|
81
|
-
c.action do |global_options, options, args|
|
|
82
|
-
command_impl_for_list global_options, options.merge(kind: "host_factory"), args
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
26
|
hf.desc "Operations on tokens"
|
|
87
27
|
hf.long_desc <<-DESC
|
|
88
28
|
This command creates one or more identical tokens. A token is always created with an
|
|
@@ -131,12 +71,10 @@ By default, this command creates one token. Optionally, it can be used to create
|
|
|
131
71
|
end
|
|
132
72
|
expiration = Time.now + duration
|
|
133
73
|
count = (options[:count] || 1).to_i
|
|
134
|
-
command_options = {}
|
|
135
74
|
|
|
136
75
|
cidr = format_cidr(options.delete(:cidr))
|
|
137
|
-
command_options[:cidr] = cidr unless cidr.nil?
|
|
138
76
|
|
|
139
|
-
tokens = api.host_factory
|
|
77
|
+
tokens = api.resource(full_resource_id("host_factory:#{id}")).create_tokens expiration, count: count, cidr: cidr
|
|
140
78
|
display tokens.map(&:to_json)
|
|
141
79
|
end
|
|
142
80
|
end
|
|
@@ -151,16 +89,6 @@ By default, this command creates one token. Optionally, it can be used to create
|
|
|
151
89
|
puts "Token revoked"
|
|
152
90
|
end
|
|
153
91
|
end
|
|
154
|
-
|
|
155
|
-
tokens.desc "Show a token"
|
|
156
|
-
tokens.arg_name "token"
|
|
157
|
-
tokens.command :show do |c|
|
|
158
|
-
c.action do |global_options,options,args|
|
|
159
|
-
token = require_arg(args, 'token')
|
|
160
|
-
|
|
161
|
-
display api.show_host_factory_token(token), options
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
92
|
end
|
|
165
93
|
|
|
166
94
|
hf.desc "Operations on hosts"
|
|
@@ -171,7 +99,7 @@ By default, this command creates one token. Optionally, it can be used to create
|
|
|
171
99
|
c.action do |global_options,options,args|
|
|
172
100
|
token = require_arg(args, 'token')
|
|
173
101
|
id = require_arg(args, 'host-id')
|
|
174
|
-
|
|
102
|
+
|
|
175
103
|
host = Conjur::API.host_factory_create_host token, id, options
|
|
176
104
|
display host
|
|
177
105
|
end
|
data/lib/conjur/command/hosts.rb
CHANGED
|
@@ -21,83 +21,11 @@
|
|
|
21
21
|
|
|
22
22
|
class Conjur::Command::Hosts < Conjur::Command
|
|
23
23
|
def self.host_layer_roles host
|
|
24
|
-
host.
|
|
24
|
+
host.memberships.select{|r| r.kind == "layer"}
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
desc "Manage hosts"
|
|
28
28
|
command :host do |hosts|
|
|
29
|
-
hosts.desc "Create a new host [DEPRECATED]"
|
|
30
|
-
hosts.arg_name "NAME"
|
|
31
|
-
hosts.command :create do |c|
|
|
32
|
-
c.arg_name "password"
|
|
33
|
-
c.flag [:p,:password]
|
|
34
|
-
|
|
35
|
-
c.desc "A comma-delimited list of CIDR addresses to restrict host to (optional)"
|
|
36
|
-
c.flag [:cidr]
|
|
37
|
-
|
|
38
|
-
acting_as_option(c)
|
|
39
|
-
|
|
40
|
-
c.action do |global_options,options,args|
|
|
41
|
-
notify_deprecated
|
|
42
|
-
|
|
43
|
-
id = args.shift
|
|
44
|
-
|
|
45
|
-
unless id
|
|
46
|
-
ActiveSupport::Deprecation.warn "id argument will be required in future releases"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
cidr = format_cidr(options.delete(:cidr))
|
|
50
|
-
options[:id] = id if id
|
|
51
|
-
options[:cidr] = cidr unless cidr.nil?
|
|
52
|
-
|
|
53
|
-
display api.create_host(options), options
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
hosts.desc "Show a host"
|
|
58
|
-
hosts.arg_name "HOST"
|
|
59
|
-
hosts.command :show do |c|
|
|
60
|
-
c.action do |global_options,options,args|
|
|
61
|
-
id = require_arg(args, 'HOST')
|
|
62
|
-
display(api.host(id), options)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
hosts.desc "Decommission a host [DEPRECATED]"
|
|
67
|
-
hosts.arg_name "HOST"
|
|
68
|
-
hosts.command :retire do |c|
|
|
69
|
-
retire_options c
|
|
70
|
-
|
|
71
|
-
c.action do |global_options,options,args|
|
|
72
|
-
notify_deprecated
|
|
73
|
-
|
|
74
|
-
id = require_arg(args, 'HOST')
|
|
75
|
-
|
|
76
|
-
host = api.host(id)
|
|
77
|
-
|
|
78
|
-
validate_retire_privileges host, options
|
|
79
|
-
|
|
80
|
-
host_layer_roles(host).each do |layer|
|
|
81
|
-
puts "Removing from layer #{layer.id}"
|
|
82
|
-
api.layer(layer.id).remove_host host
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
retire_resource host
|
|
86
|
-
retire_role host
|
|
87
|
-
give_away_resource host, options
|
|
88
|
-
|
|
89
|
-
puts "Host retired"
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
hosts.desc "List hosts"
|
|
94
|
-
hosts.command :list do |c|
|
|
95
|
-
command_options_for_list c
|
|
96
|
-
c.action do |global_options, options, args|
|
|
97
|
-
command_impl_for_list global_options, options.merge(kind: "host"), args
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
29
|
hosts.desc "Rotate a host's API key"
|
|
102
30
|
hosts.command :rotate_api_key do |c|
|
|
103
31
|
c.desc "Login of host whose API key we want to rotate (default: logged-in host)"
|
|
@@ -105,8 +33,9 @@ class Conjur::Command::Hosts < Conjur::Command
|
|
|
105
33
|
c.action do |_global, options, _args|
|
|
106
34
|
if options.include?(:host)
|
|
107
35
|
host = options[:host]
|
|
36
|
+
host_resourceid = full_resource_id("host:#{host}")
|
|
108
37
|
|
|
109
|
-
unless api.
|
|
38
|
+
unless api.resource(host_resourceid).exists?
|
|
110
39
|
exit_now! "host '#{host}' not found"
|
|
111
40
|
end
|
|
112
41
|
|
|
@@ -117,10 +46,10 @@ class Conjur::Command::Hosts < Conjur::Command
|
|
|
117
46
|
|
|
118
47
|
# Make sure we're not trying to rotate our own key with the user flag.
|
|
119
48
|
if api.username == host
|
|
120
|
-
exit_now! 'To rotate
|
|
49
|
+
exit_now! 'To rotate the API key of the currently logged-in host, use this command without any flags or options'
|
|
121
50
|
end
|
|
122
51
|
|
|
123
|
-
puts api.
|
|
52
|
+
puts api.resource(host_resourceid).rotate_api_key
|
|
124
53
|
else
|
|
125
54
|
username, password = Conjur::Authn.read_credentials
|
|
126
55
|
# Make sure the current identity is a host
|
|
@@ -136,48 +65,12 @@ class Conjur::Command::Hosts < Conjur::Command
|
|
|
136
65
|
end
|
|
137
66
|
end
|
|
138
67
|
|
|
139
|
-
hosts.desc "Update a hosts's attributes [DEPRECATED]"
|
|
140
|
-
hosts.arg_name "HOST"
|
|
141
|
-
hosts.command :update do |c|
|
|
142
|
-
c.desc "A comma-delimited list of CIDR addresses to restrict host to (optional). Use 'all' to reset"
|
|
143
|
-
c.flag [:cidr]
|
|
144
|
-
|
|
145
|
-
c.action do |global_options, options, args|
|
|
146
|
-
notify_deprecated
|
|
147
|
-
|
|
148
|
-
id = require_arg(args, 'HOST')
|
|
149
|
-
|
|
150
|
-
host = api.host(id)
|
|
151
|
-
|
|
152
|
-
cidr = format_cidr(options[:cidr])
|
|
153
|
-
|
|
154
|
-
host_options = { }
|
|
155
|
-
host_options[:cidr] = cidr unless cidr.nil?
|
|
156
|
-
|
|
157
|
-
host.update(host_options)
|
|
158
|
-
puts "Host updated"
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
hosts.desc "Enroll a new host into conjur [DEPRECATED]"
|
|
163
|
-
hosts.arg_name "HOST"
|
|
164
|
-
hosts.command :enroll do |c|
|
|
165
|
-
hide_docs(c)
|
|
166
|
-
c.action do |global_options, options, args|
|
|
167
|
-
id = require_arg(args, 'HOST')
|
|
168
|
-
enrollment_url = api.host(id).enrollment_url
|
|
169
|
-
puts enrollment_url
|
|
170
|
-
$stderr.puts "On the target host, please execute the following command:"
|
|
171
|
-
$stderr.puts "curl -L #{enrollment_url} | bash"
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
68
|
hosts.desc "List the layers to which the host belongs"
|
|
176
69
|
hosts.arg_name "HOST"
|
|
177
70
|
hosts.command :layers do |c|
|
|
178
71
|
c.action do |global_options, options, args|
|
|
179
72
|
id = require_arg(args, 'HOST')
|
|
180
|
-
host = api.host
|
|
73
|
+
host = api.resource(full_resource_id("host:#{id}"))
|
|
181
74
|
display host_layer_roles(host).map(&:identifier), options
|
|
182
75
|
end
|
|
183
76
|
end
|
data/lib/conjur/command/init.rb
CHANGED
|
@@ -38,11 +38,11 @@ class Conjur::Command::Init < Conjur::Command
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
Conjur::CLI.command :init do |c|
|
|
41
|
-
c.desc "
|
|
42
|
-
c.arg_name '
|
|
43
|
-
c.flag ["
|
|
41
|
+
c.desc "URL of the Conjur service"
|
|
42
|
+
c.arg_name 'URL'
|
|
43
|
+
c.flag ["u", "url"]
|
|
44
44
|
|
|
45
|
-
c.desc "Conjur organization account name
|
|
45
|
+
c.desc "Conjur organization account name"
|
|
46
46
|
c.flag ["a", "account"]
|
|
47
47
|
|
|
48
48
|
c.desc "Conjur SSL certificate (will be obtained from host unless provided by this option)"
|
|
@@ -56,40 +56,26 @@ class Conjur::Command::Init < Conjur::Command
|
|
|
56
56
|
c.flag "force"
|
|
57
57
|
|
|
58
58
|
c.action do |global_options,options,args|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
exit_now! "only https protocol supported" unless protocol.nil? || protocol == 'https'
|
|
62
|
-
if hostname
|
|
63
|
-
Conjur.configuration.core_url = "https://#{hostname}/api"
|
|
64
|
-
end
|
|
59
|
+
url = options[:url] || highline.ask("Enter the URL of your Conjur service: ").to_s
|
|
60
|
+
url = URI.parse(url)
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
puts "\nPlease verify this certificate on the appliance using command:
|
|
79
|
-
openssl x509 -fingerprint -noout -in ~conjur/etc/ssl/conjur.pem\n\n"
|
|
80
|
-
exit_now! "You decided not to trust the certificate" unless highline.ask("Trust this certificate (yes/no): ").strip == "yes"
|
|
81
|
-
end
|
|
62
|
+
Conjur.configuration.appliance_url = url.to_s
|
|
63
|
+
|
|
64
|
+
if (certificate = options[:certificate]).blank? && url.scheme == "https"
|
|
65
|
+
connect_hostname = [ url.host, url.port ].join(":")
|
|
66
|
+
fingerprint, certificate = get_certificate connect_hostname
|
|
67
|
+
|
|
68
|
+
puts
|
|
69
|
+
puts fingerprint
|
|
70
|
+
|
|
71
|
+
puts "\nPlease verify this certificate on the appliance using command:
|
|
72
|
+
openssl x509 -fingerprint -noout -in ~conjur/etc/ssl/conjur.pem\n\n"
|
|
73
|
+
exit_now! "You decided not to trust the certificate" unless highline.ask("Trust this certificate (yes/no): ").strip == "yes"
|
|
82
74
|
end
|
|
83
75
|
|
|
84
76
|
configure_cert_store certificate
|
|
85
77
|
|
|
86
|
-
account = options[:account]
|
|
87
|
-
account ||= if hostname
|
|
88
|
-
account = Conjur::Core::API.info['account'] or raise "Expecting 'account' in Core info"
|
|
89
|
-
else
|
|
90
|
-
# using .to_s to overcome https://github.com/JEG2/highline/issues/69
|
|
91
|
-
highline.ask("Enter your organization account name: ").to_s
|
|
92
|
-
end
|
|
78
|
+
account = options[:account] || highline.ask("Enter your organization account name: ").to_s
|
|
93
79
|
|
|
94
80
|
exit_now! "account is required" if account.blank?
|
|
95
81
|
|
|
@@ -98,7 +84,7 @@ class Conjur::Command::Init < Conjur::Command
|
|
|
98
84
|
plugins: []
|
|
99
85
|
}
|
|
100
86
|
|
|
101
|
-
config[:appliance_url] =
|
|
87
|
+
config[:appliance_url] = url.to_s
|
|
102
88
|
|
|
103
89
|
config_file = File.expand_path('~/.conjurrc')
|
|
104
90
|
|
|
@@ -140,7 +126,6 @@ class Conjur::Command::Init < Conjur::Command
|
|
|
140
126
|
|
|
141
127
|
sock = TCPSocket.new host, port.to_i
|
|
142
128
|
ssock = SSLSocket.new sock
|
|
143
|
-
ssock.hostname = host
|
|
144
129
|
ssock.connect
|
|
145
130
|
chain = ssock.peer_cert_chain
|
|
146
131
|
cert = chain.first
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright (C)
|
|
2
|
+
# Copyright (C) 2017 Conjur Inc
|
|
3
3
|
#
|
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
5
|
# this software and associated documentation files (the "Software"), to deal in
|
|
@@ -17,30 +17,41 @@
|
|
|
17
17
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
18
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
class Conjur::Command::Secrets < Conjur::Command
|
|
23
|
-
desc "Manage secrets"
|
|
24
|
-
command :secret do |secret|
|
|
25
|
-
hide_docs(secret)
|
|
26
|
-
secret.desc "Create and store a secret"
|
|
27
|
-
secret.arg_name "secret"
|
|
28
|
-
secret.command :create do |c|
|
|
29
|
-
acting_as_option(c)
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
class Conjur::Command::Policies < Conjur::Command
|
|
22
|
+
desc "Manage policies"
|
|
23
|
+
command :policy do |p|
|
|
24
|
+
p.desc "Load a policy"
|
|
25
|
+
p.arg_name "POLICY FILENAME"
|
|
26
|
+
p.command :load do |c|
|
|
27
|
+
c.desc "Fully replace the existing policy, deleting any data that is not declared in the new policy."
|
|
28
|
+
c.switch :replace
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
c.desc "Allow explicit deletion statements in the policy."
|
|
31
|
+
c.switch :delete
|
|
32
|
+
|
|
40
33
|
c.action do |global_options,options,args|
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
policy_id = require_arg(args, 'POLICY')
|
|
35
|
+
filename = require_arg(args, 'FILENAME')
|
|
36
|
+
policy = if filename == '-'
|
|
37
|
+
STDIN.read
|
|
38
|
+
else
|
|
39
|
+
require 'open-uri'
|
|
40
|
+
open(filename).read
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
method = if options[:replace]
|
|
44
|
+
Conjur::API::POLICY_METHOD_PUT
|
|
45
|
+
elsif options[:delete]
|
|
46
|
+
Conjur::API::POLICY_METHOD_PATCH
|
|
47
|
+
else
|
|
48
|
+
Conjur::API::POLICY_METHOD_POST
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
result = api.load_policy policy_id, policy, method: method
|
|
52
|
+
$stderr.puts "Loaded policy '#{policy_id}'"
|
|
53
|
+
puts JSON.pretty_generate(result)
|
|
43
54
|
end
|
|
44
55
|
end
|
|
45
56
|
end
|
|
46
|
-
end
|
|
57
|
+
end
|