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
|
@@ -3,9 +3,10 @@ shared_context "with fake endpoints and test config" do
|
|
|
3
3
|
let(:authz_host) { 'https://authz.example.com' }
|
|
4
4
|
let(:core_host) { 'https://core.example.com/api' }
|
|
5
5
|
before do
|
|
6
|
-
allow(Conjur
|
|
7
|
-
allow(Conjur
|
|
8
|
-
allow(Conjur
|
|
6
|
+
allow(Conjur.configuration).to receive(:account) { account }
|
|
7
|
+
allow(Conjur.configuration).to receive(:authn_url) { authn_host }
|
|
8
|
+
allow(Conjur.configuration).to receive(:authz_url) { authz_host }
|
|
9
|
+
allow(Conjur.configuration).to receive(:core_url) { core_host }
|
|
9
10
|
|
|
10
11
|
ENV['GLI_DEBUG'] = 'true'
|
|
11
12
|
end
|
|
@@ -20,7 +21,6 @@ shared_context "with mock authn" do
|
|
|
20
21
|
let(:api_key) { 'sekrit' }
|
|
21
22
|
let(:api) { Conjur::API.new_from_key(username, api_key) }
|
|
22
23
|
before do
|
|
23
|
-
allow(Conjur::Core::API).to receive(:conjur_account) { account }
|
|
24
24
|
allow(Conjur::Authn).to receive_messages(netrc: netrc, host: authn_host)
|
|
25
25
|
Conjur::Config.merge 'account' => account
|
|
26
26
|
end
|
data/lib/conjur/command/users.rb
CHANGED
|
@@ -24,116 +24,6 @@ class Conjur::Command::Users < Conjur::Command
|
|
|
24
24
|
desc "Manage users"
|
|
25
25
|
command :user do |user|
|
|
26
26
|
|
|
27
|
-
user.desc "Create a new user [DEPRECATED]"
|
|
28
|
-
user.arg_name "NAME"
|
|
29
|
-
user.command :create do |c|
|
|
30
|
-
c.desc "Prompt for a password for the user (default: --no-password)"
|
|
31
|
-
c.switch [:p,:password]
|
|
32
|
-
|
|
33
|
-
c.desc "UID number to be associated with user (optional)"
|
|
34
|
-
c.flag [:uidnumber]
|
|
35
|
-
|
|
36
|
-
c.desc "A comma-delimited list of CIDR addresses to restrict user to (optional)"
|
|
37
|
-
c.flag [:cidr]
|
|
38
|
-
|
|
39
|
-
acting_as_option(c)
|
|
40
|
-
|
|
41
|
-
interactive_option c
|
|
42
|
-
|
|
43
|
-
c.action do |global_options,options,args|
|
|
44
|
-
notify_deprecated
|
|
45
|
-
|
|
46
|
-
login = args.shift
|
|
47
|
-
|
|
48
|
-
interactive = options[:interactive] || login.blank?
|
|
49
|
-
|
|
50
|
-
groupid = options[:ownerid]
|
|
51
|
-
uidnumber = options[:uidnumber]
|
|
52
|
-
cidr = format_cidr(options[:cidr])
|
|
53
|
-
password = nil
|
|
54
|
-
|
|
55
|
-
validate_uidnumber(uidnumber)
|
|
56
|
-
|
|
57
|
-
if interactive
|
|
58
|
-
login ||= prompt_for_id :user, "login name"
|
|
59
|
-
|
|
60
|
-
groupid ||= prompt_for_group hint: "press enter to have the user own their own record"
|
|
61
|
-
uidnumber ||= prompt_for_uidnumber
|
|
62
|
-
password = prompt_for_password unless options[:"no-password"]
|
|
63
|
-
|
|
64
|
-
attributes = {
|
|
65
|
-
"Login" => login,
|
|
66
|
-
"Owner" => groupid,
|
|
67
|
-
"UID Number" => uidnumber,
|
|
68
|
-
"CIDR" => cidr
|
|
69
|
-
}
|
|
70
|
-
attributes["Password"] = "********" unless password.blank?
|
|
71
|
-
prompt_to_confirm :user, attributes
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
if options[:p] && password.blank?
|
|
75
|
-
password = prompt_for_password
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
user_options = { }
|
|
79
|
-
user_options[:ownerid] = groupid if groupid
|
|
80
|
-
user_options[:uidnumber] = uidnumber.to_i if uidnumber
|
|
81
|
-
user_options[:cidr] = cidr unless cidr.nil?
|
|
82
|
-
user_options[:password] = password if password
|
|
83
|
-
user = api.create_user(login, user_options)
|
|
84
|
-
|
|
85
|
-
display user
|
|
86
|
-
|
|
87
|
-
if interactive
|
|
88
|
-
public_key = prompt_for_public_key
|
|
89
|
-
if public_key
|
|
90
|
-
api.add_public_key user.login, public_key
|
|
91
|
-
puts "Public key added"
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
user.desc "Show a user"
|
|
98
|
-
user.arg_name "USER"
|
|
99
|
-
user.command :show do |c|
|
|
100
|
-
c.action do |global_options,options,args|
|
|
101
|
-
id = require_arg(args, 'USER')
|
|
102
|
-
display(api.user(id), options)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
user.desc "Decommission a user [DEPRECATED]"
|
|
107
|
-
user.arg_name "USER"
|
|
108
|
-
user.command :retire do |c|
|
|
109
|
-
retire_options c
|
|
110
|
-
|
|
111
|
-
c.action do |global_options,options,args|
|
|
112
|
-
notify_deprecated
|
|
113
|
-
|
|
114
|
-
id = require_arg(args, 'USER')
|
|
115
|
-
|
|
116
|
-
user = api.user(id)
|
|
117
|
-
|
|
118
|
-
validate_retire_privileges user, options
|
|
119
|
-
|
|
120
|
-
retire_resource user
|
|
121
|
-
retire_role user
|
|
122
|
-
give_away_resource user, options
|
|
123
|
-
|
|
124
|
-
puts "User retired"
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
user.desc "List users"
|
|
129
|
-
user.command :list do |c|
|
|
130
|
-
command_options_for_list c
|
|
131
|
-
|
|
132
|
-
c.action do |global_options, options, args|
|
|
133
|
-
command_impl_for_list global_options, options.merge(kind: "user"), args
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
27
|
user.desc "Update the password of the logged-in user"
|
|
138
28
|
user.command :update_password do |c|
|
|
139
29
|
c.desc "Password to use, otherwise you will be prompted"
|
|
@@ -155,9 +45,9 @@ class Conjur::Command::Users < Conjur::Command
|
|
|
155
45
|
if options.include?(:user)
|
|
156
46
|
# Make sure we're not trying to rotate our own key with the user flag.
|
|
157
47
|
if api.username == options[:user]
|
|
158
|
-
exit_now! 'To rotate
|
|
48
|
+
exit_now! 'To rotate the API key of the currently logged-in user, use this command without any flags or options'
|
|
159
49
|
end
|
|
160
|
-
puts api.user
|
|
50
|
+
puts api.resource([ Conjur.configuration.account, "user", options[:user] ].join(":")).rotate_api_key
|
|
161
51
|
else
|
|
162
52
|
username, password = Conjur::Authn.read_credentials
|
|
163
53
|
new_api_key = Conjur::API.rotate_api_key username, password
|
|
@@ -167,49 +57,6 @@ class Conjur::Command::Users < Conjur::Command
|
|
|
167
57
|
end
|
|
168
58
|
end
|
|
169
59
|
end
|
|
170
|
-
|
|
171
|
-
user.desc "Update a user's attributes [DEPRECATED]"
|
|
172
|
-
user.arg_name "USER"
|
|
173
|
-
user.command :update do |c|
|
|
174
|
-
c.desc "UID number to be associated with user (optional)"
|
|
175
|
-
c.flag [:uidnumber]
|
|
176
|
-
|
|
177
|
-
c.desc "A comma-delimited list of CIDR addresses to restrict user to (optional). Use 'all' to reset"
|
|
178
|
-
c.flag [:cidr]
|
|
179
|
-
|
|
180
|
-
c.action do |global_options, options, args|
|
|
181
|
-
notify_deprecated
|
|
182
|
-
|
|
183
|
-
login=require_arg(args,'USER')
|
|
184
|
-
|
|
185
|
-
uidnumber = options[:uidnumber]
|
|
186
|
-
cidr = format_cidr(options[:cidr])
|
|
187
|
-
|
|
188
|
-
validate_uidnumber(uidnumber)
|
|
189
|
-
|
|
190
|
-
user_options = { }
|
|
191
|
-
user_options[:uidnumber] = uidnumber.to_i if uidnumber
|
|
192
|
-
user_options[:cidr] = cidr unless cidr.nil?
|
|
193
|
-
|
|
194
|
-
api.user(login).update(user_options)
|
|
195
|
-
puts "User updated"
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
user.desc "Find the user by UID"
|
|
200
|
-
user.arg_name "uid"
|
|
201
|
-
user.command :uidsearch do |c|
|
|
202
|
-
c.action do |global_options, options, args|
|
|
203
|
-
uidnumber = require_arg(args,'uid')
|
|
204
|
-
raise "Uidnumber should be integer" unless /\d+/ =~ uidnumber
|
|
205
|
-
uidnumber=uidnumber.to_i
|
|
206
|
-
display api.find_users(uidnumber: uidnumber)
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def self.prompt_for_uidnumber
|
|
212
|
-
prompt_for_idnumber "uid number"
|
|
213
60
|
end
|
|
214
61
|
|
|
215
62
|
def self.format_cidr(cidr)
|
|
@@ -222,8 +69,4 @@ class Conjur::Command::Users < Conjur::Command
|
|
|
222
69
|
cidr.split(',').each {|x| x.strip!}
|
|
223
70
|
end
|
|
224
71
|
end
|
|
225
|
-
|
|
226
|
-
def self.validate_uidnumber(uidnumber)
|
|
227
|
-
exit_now! 'uidnumber should be integer' unless uidnumber.blank? || /\d+/ =~ uidnumber
|
|
228
|
-
end
|
|
229
72
|
end
|
|
@@ -21,116 +21,6 @@
|
|
|
21
21
|
class Conjur::Command::Variables < Conjur::Command
|
|
22
22
|
desc "Manage variables"
|
|
23
23
|
command :variable do |var|
|
|
24
|
-
var.desc "Create and store a variable [DEPRECATED]"
|
|
25
|
-
var.arg_name "NAME VALUE"
|
|
26
|
-
var.command :create do |c|
|
|
27
|
-
c.arg_name "MIME-TYPE"
|
|
28
|
-
c.flag [:m, :"mime-type"], default_value: 'text/plain'
|
|
29
|
-
|
|
30
|
-
c.arg_name "KIND"
|
|
31
|
-
c.flag [:k, :"kind"], default_value: 'secret'
|
|
32
|
-
|
|
33
|
-
c.arg_name "VALUE"
|
|
34
|
-
c.desc "Initial value, which may also be specified as the second command argument after the variable id"
|
|
35
|
-
c.flag [:v, :"value"]
|
|
36
|
-
|
|
37
|
-
acting_as_option c
|
|
38
|
-
|
|
39
|
-
annotate_option c
|
|
40
|
-
|
|
41
|
-
interactive_option c
|
|
42
|
-
|
|
43
|
-
c.action do |global_options,options, args|
|
|
44
|
-
notify_deprecated
|
|
45
|
-
|
|
46
|
-
@default_mime_type = c.flags[:m].default_value
|
|
47
|
-
@default_kind = c.flags[:k].default_value
|
|
48
|
-
|
|
49
|
-
id = args.shift unless args.empty?
|
|
50
|
-
value = args.shift unless args.empty?
|
|
51
|
-
|
|
52
|
-
exit_now! "Received conflicting value arguments" if value && options[:value]
|
|
53
|
-
|
|
54
|
-
groupid = options[:ownerid]
|
|
55
|
-
mime_type = options[:m]
|
|
56
|
-
kind = options[:k]
|
|
57
|
-
value ||= options[:v]
|
|
58
|
-
interactive = options[:interactive] || id.blank?
|
|
59
|
-
annotate = options[:annotate]
|
|
60
|
-
|
|
61
|
-
exit_now! "Received --annotate option without --interactive" if annotate && !interactive
|
|
62
|
-
|
|
63
|
-
annotations = {}
|
|
64
|
-
# If the user asked for interactive mode, or he didn't specify and id
|
|
65
|
-
# prompt for any missing options.
|
|
66
|
-
if interactive
|
|
67
|
-
id ||= prompt_for_id :variable
|
|
68
|
-
|
|
69
|
-
groupid ||= prompt_for_group
|
|
70
|
-
|
|
71
|
-
kind = prompt_for_kind if !kind || kind == @default_kind
|
|
72
|
-
|
|
73
|
-
mime_type = prompt_for_mime_type if mime_type.blank? || mime_type == @default_mime_type
|
|
74
|
-
|
|
75
|
-
annotations = prompt_for_annotations if annotate
|
|
76
|
-
|
|
77
|
-
value ||= prompt_for_value
|
|
78
|
-
|
|
79
|
-
prompt_to_confirm :variable, "Id" => id,
|
|
80
|
-
"Kind" => kind,
|
|
81
|
-
"MIME type" => mime_type,
|
|
82
|
-
"Owner" => groupid,
|
|
83
|
-
"Value" => value
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
variable_options = { id: id }
|
|
87
|
-
variable_options[:ownerid] = groupid if groupid
|
|
88
|
-
variable_options[:value] = value unless value.blank?
|
|
89
|
-
var = api.create_variable(mime_type, kind, variable_options)
|
|
90
|
-
api.resource(var).annotations.merge!(annotations) if annotations && !annotations.empty?
|
|
91
|
-
display(var, options)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
var.desc "Show a variable"
|
|
96
|
-
var.arg_name "VARIABLE"
|
|
97
|
-
var.command :show do |c|
|
|
98
|
-
c.action do |global_options,options,args|
|
|
99
|
-
id = require_arg(args, 'VARIABLE')
|
|
100
|
-
display(api.variable(id), options)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
var.desc "Decommission a variable [DEPRECATED]"
|
|
105
|
-
var.arg_name "VARIABLE"
|
|
106
|
-
var.command :retire do |c|
|
|
107
|
-
retire_options c
|
|
108
|
-
|
|
109
|
-
c.action do |global_options,options,args|
|
|
110
|
-
notify_deprecated
|
|
111
|
-
|
|
112
|
-
id = require_arg(args, 'VARIABLE')
|
|
113
|
-
|
|
114
|
-
variable = api.variable(id)
|
|
115
|
-
|
|
116
|
-
validate_retire_privileges variable, options
|
|
117
|
-
|
|
118
|
-
retire_resource variable
|
|
119
|
-
give_away_resource variable, options
|
|
120
|
-
|
|
121
|
-
puts "Variable retired"
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
var.desc "List variables"
|
|
126
|
-
var.command :list do |c|
|
|
127
|
-
command_options_for_list c
|
|
128
|
-
|
|
129
|
-
c.action do |global_options, options, args|
|
|
130
|
-
command_impl_for_list global_options, options.merge(kind: "variable"), args
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
24
|
var.desc "Access variable values"
|
|
135
25
|
var.command :values do |values|
|
|
136
26
|
values.desc "Add a value"
|
|
@@ -139,8 +29,9 @@ class Conjur::Command::Variables < Conjur::Command
|
|
|
139
29
|
c.action do |global_options,options,args|
|
|
140
30
|
id = require_arg(args, 'VARIABLE')
|
|
141
31
|
value = args.shift || STDIN.read
|
|
32
|
+
assert_empty(args)
|
|
142
33
|
|
|
143
|
-
api.variable
|
|
34
|
+
api.resource(full_resource_id("variable:#{id}")).add_value(value)
|
|
144
35
|
puts "Value added"
|
|
145
36
|
end
|
|
146
37
|
end
|
|
@@ -154,114 +45,10 @@ class Conjur::Command::Variables < Conjur::Command
|
|
|
154
45
|
|
|
155
46
|
c.action do |global_options,options,args|
|
|
156
47
|
id = require_arg(args, 'VARIABLE')
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var.desc 'Set the expiration for a variable'
|
|
162
|
-
var.command :expire do |c|
|
|
163
|
-
c.arg_name "NOW"
|
|
164
|
-
c.desc 'Set variable to expire immediately'
|
|
165
|
-
min_version c, '4.6.0'
|
|
166
|
-
c.switch [:n, :'now'], :negatable => false
|
|
167
|
-
|
|
168
|
-
c.arg_name "DAYS"
|
|
169
|
-
c.desc 'Set variable to expire after the given number of days'
|
|
170
|
-
c.flag [:d, :'days']
|
|
171
|
-
|
|
172
|
-
c.arg_name "MONTHS"
|
|
173
|
-
c.desc 'Set variable to expire after the given number of months'
|
|
174
|
-
c.flag [:m, :'months']
|
|
175
|
-
|
|
176
|
-
c.arg_name "DURATION"
|
|
177
|
-
c.desc 'Set variable to expire after the given ISO8601 duration'
|
|
178
|
-
c.flag [:i, :'in']
|
|
179
|
-
|
|
180
|
-
c.action do |global_options, options, args|
|
|
181
|
-
id = require_arg(args, 'VARIABLE')
|
|
182
|
-
|
|
183
|
-
exit_now! 'Specify only one duration' if durations(options) > 1
|
|
184
|
-
exit_now! 'Specify at least one duration' if durations(options) == 0
|
|
185
|
-
|
|
186
|
-
now = options[:n]
|
|
187
|
-
days = options[:d]
|
|
188
|
-
months = options[:m]
|
|
189
|
-
|
|
190
|
-
case
|
|
191
|
-
when now.present?
|
|
192
|
-
duration = 'P0Y'
|
|
193
|
-
when days.present?
|
|
194
|
-
duration = "P#{days.to_i}D"
|
|
195
|
-
when months.present?
|
|
196
|
-
duration = "P#{months.to_i}M"
|
|
197
|
-
else
|
|
198
|
-
duration = options[:i]
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
display api.variable(id).expires_in(duration)
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
var.desc 'Display expiring variables'
|
|
206
|
-
var.long_desc 'Only variables that expire within the given duration are displayed. If no duration is provided, show all visible variables that are set to expire.'
|
|
207
|
-
var.command :expirations do |c|
|
|
208
|
-
c.arg_name 'DAYS'
|
|
209
|
-
c.desc 'Display variables that expire within the given number of days'
|
|
210
|
-
min_version c, '4.6.0'
|
|
211
|
-
c.flag [:d, :'days']
|
|
212
|
-
|
|
213
|
-
c.arg_name 'MONTHS'
|
|
214
|
-
c.desc 'Display variables that expire within the given number of months'
|
|
215
|
-
c.flag [:m, :'months']
|
|
216
|
-
|
|
217
|
-
c.arg_name 'IN'
|
|
218
|
-
c.desc 'Display variables that expire within the given ISO8601 interval'
|
|
219
|
-
c.flag [:i, :'in']
|
|
220
|
-
|
|
221
|
-
c.action do | global_options, options, args|
|
|
222
|
-
|
|
223
|
-
days = options[:d]
|
|
224
|
-
months = options[:m]
|
|
225
|
-
duration = options[:i]
|
|
226
|
-
|
|
227
|
-
exit_now! 'Specify only one duration' if durations(options) > 1
|
|
228
|
-
|
|
229
|
-
case
|
|
230
|
-
when days.present?
|
|
231
|
-
duration = "P#{days.to_i}D"
|
|
232
|
-
when months.present?
|
|
233
|
-
duration = "P#{months.to_i}M"
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
display api.variable_expirations(duration)
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
class << self
|
|
243
|
-
def prompt_for_kind
|
|
244
|
-
highline.ask('Enter the kind: ') {|q| q.default = @default_kind }
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
def prompt_for_mime_type
|
|
248
|
-
highline.choose do |menu|
|
|
249
|
-
menu.prompt = 'Enter the MIME type: '
|
|
250
|
-
menu.choice @default_mime_type
|
|
251
|
-
menu.choices *%w(application/json application/xml application/x-yaml application/x-pem-file)
|
|
252
|
-
menu.choice "other", nil do |c|
|
|
253
|
-
@highline.ask('Enter a custom mime type: ')
|
|
254
|
-
end
|
|
48
|
+
assert_empty(args)
|
|
49
|
+
|
|
50
|
+
$stdout.write api.resource(full_resource_id("variable:#{id}")).value(options[:version])
|
|
255
51
|
end
|
|
256
52
|
end
|
|
257
|
-
|
|
258
|
-
def prompt_for_value
|
|
259
|
-
read_till_eof('Enter the secret value (^D on its own line to finish):')
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def durations(options)
|
|
263
|
-
[options[:n],options[:d],options[:m],options[:i]].count {|o| o.present?}
|
|
264
|
-
end
|
|
265
53
|
end
|
|
266
|
-
|
|
267
54
|
end
|