phoseum-cli 0.0.21 → 0.0.22
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 +4 -4
- data/bin/phoseum-cli +19 -44
- data/lib/phoseum/phoseum-cli-lib.rb +1 -1
- data/lib/phoseum/phoseum-common-lib.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda101298c10dfba931a42da89cf49f7621341ab94c6f6eb5b763d17abe36084
|
4
|
+
data.tar.gz: 3b60673f5aa9ace4862570622496360d83352d89407d9863cf4f2391ba73efb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113d85253686c204b3eaa02643050193cdb7a65ea33e1654b7fa8da1c1e65f56b197db195c0f4cc9059f447a4781c18f5b48afce52dd5b7b36e23ff25657d6dd
|
7
|
+
data.tar.gz: 46efcbf1a8b7679f9c0888355ebc1963f047bc56ab079b9122f9e0050b84ab4162b6d4906066b4b213d8410b16c544475664ceed0fccb2a86bbb3948bedf8771
|
data/bin/phoseum-cli
CHANGED
@@ -237,45 +237,6 @@ def health(what='',name='')
|
|
237
237
|
exit 0
|
238
238
|
end
|
239
239
|
|
240
|
-
def user_mgmt(action,user,pass='',role='')
|
241
|
-
post_body={}
|
242
|
-
if action == "add_user"
|
243
|
-
post_body=JSON.generate({"action" => "create-user", "user" => "#{user}", "password" => "#{pass}", "role" => "#{role}"})
|
244
|
-
if !$config['DEFAULT_SECRET']
|
245
|
-
puts "You must have a DEFAULT_SECRET setting to be able to create a user".red
|
246
|
-
exit 1
|
247
|
-
end
|
248
|
-
end
|
249
|
-
base = URI.parse("#{$config['SERVERURL']}")
|
250
|
-
puts "\nConnecting to: #{$config['SERVERURL']}".yellow if !$QUIET
|
251
|
-
request = Net::HTTP::Post.new(base)
|
252
|
-
request.body = post_body
|
253
|
-
request.basic_auth("auth", $config['DEFAULT_SECRET'])
|
254
|
-
response = Net::HTTP.start(base.hostname, $config['PORT'],
|
255
|
-
:timeout => $config['CALL_TIMEOUT'],
|
256
|
-
:use_ssl => base.scheme == "https",
|
257
|
-
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
|
258
|
-
:ca_file => $config['CA_TRUST']
|
259
|
-
) do |http|
|
260
|
-
http.request(request)
|
261
|
-
end
|
262
|
-
begin
|
263
|
-
list = JSON.parse(response.body)
|
264
|
-
if list['error']
|
265
|
-
puts list['error'].red
|
266
|
-
exit 1
|
267
|
-
end
|
268
|
-
if list['success']
|
269
|
-
data=list['success']
|
270
|
-
puts data
|
271
|
-
end
|
272
|
-
rescue
|
273
|
-
puts "Error on Login".red
|
274
|
-
puts clean_html(response.body)
|
275
|
-
end
|
276
|
-
exit 0
|
277
|
-
end
|
278
|
-
|
279
240
|
def user_login(puser='',ppass='')
|
280
241
|
|
281
242
|
server_value = cross_versions()
|
@@ -388,6 +349,17 @@ case options
|
|
388
349
|
end
|
389
350
|
health(what,value)
|
390
351
|
when -> (cre) { cre[:create_user] }
|
352
|
+
secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
|
353
|
+
if secretinfo['error']
|
354
|
+
err_msg = JSON.parse(secretinfo)
|
355
|
+
puts err_msg['error'].red
|
356
|
+
puts "You will only be able to change your own password.".red
|
357
|
+
exit 1
|
358
|
+
end
|
359
|
+
if secretinfo['success']
|
360
|
+
puts secretinfo['success'].green
|
361
|
+
end
|
362
|
+
|
391
363
|
if options[:create_user]
|
392
364
|
value=check_string_sanity(options[:create_user])
|
393
365
|
username_sanity(value)
|
@@ -401,15 +373,18 @@ case options
|
|
401
373
|
new_password=STDIN.getpass('Password: ')
|
402
374
|
print "\t"
|
403
375
|
confirm=STDIN.getpass('Confirm: ')
|
404
|
-
password_sanity(new_password)
|
405
376
|
if new_password == confirm
|
406
|
-
|
377
|
+
password_sanity(new_password)
|
378
|
+
if add_user(value,confirm,options[:role])
|
407
379
|
puts "User #{value} added successfully".green
|
408
380
|
exit 0
|
409
381
|
else
|
410
382
|
puts "Failed to add User #{value}".red
|
411
383
|
exit 1
|
412
|
-
end
|
384
|
+
end
|
385
|
+
else
|
386
|
+
puts "Passwords won't match, aborting. #{new_password} != #{confirm}".red
|
387
|
+
exit 1
|
413
388
|
end
|
414
389
|
end
|
415
390
|
end
|
@@ -451,7 +426,7 @@ case options
|
|
451
426
|
if options[:user]
|
452
427
|
what='user'
|
453
428
|
value=options[:user]
|
454
|
-
secretinfo = api_caller({"action" => "check-secret"},true)
|
429
|
+
secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
|
455
430
|
if secretinfo['error']
|
456
431
|
err_msg = JSON.parse(secretinfo)
|
457
432
|
puts err_msg['error'].red
|
@@ -493,7 +468,7 @@ case options
|
|
493
468
|
puts "Current user is #{auth_user}".green
|
494
469
|
end
|
495
470
|
|
496
|
-
secretinfo = api_caller({"action" => "check-secret"},true)
|
471
|
+
secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
|
497
472
|
if secretinfo['error']
|
498
473
|
err_msg = JSON.parse(secretinfo)
|
499
474
|
puts err_msg['error'].red
|