Class: Morpheus::Cli::AuthCommand
- Inherits:
-
Object
- Object
- Morpheus::Cli::AuthCommand
show all
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/auth_command.rb
Overview
JD: this is not in use, we have login, logout and access-token instead This provides commands for authentication This also includes credential management.
Instance Attribute Summary
Attributes included from CliCommand
#no_prompt
Instance Method Summary
collapse
Methods included from CliCommand
#apply_options, #build_common_options, #build_option_type_options, #build_standard_add_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_name, #default_refresh_interval, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #get_subcommand_description, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_bytes_param, #parse_id_list, #parse_list_options, #parse_list_subtitles, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #render_with_format, #run_command_for_each_arg, #subcommand_aliases, #subcommand_description, #subcommand_usage, #subcommands, #usage, #verify_args!, #visible_subcommands
Instance Method Details
#connect(options) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/morpheus/cli/auth_command.rb', line 19
def connect(options)
@api_client = establish_remote_appliance_connection(options.merge({:no_prompt => true, :skip_verify_access_token => true, :skip_login => true}))
if !@appliance_name
raise_command_error "#{command_name} requires a remote to be specified, use -r [remote] or set the active remote with `remote use`"
end
if !@appliance_url
unless options[:quiet]
print red,"Unable to determine remote appliance url. Review your remote configuration.#{reset}\n"
end
return 1
end
if @wallet.nil? || @wallet['access_token'].nil?
unless options[:quiet]
print_error yellow,"You are not currently logged in to #{display_appliance(@appliance_name, @appliance_url)}",reset,"\n"
print_error yellow,"Use `login` to authenticate.",reset,"\n"
end
return 1
end
end
|
#get(args) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/morpheus/cli/auth_command.rb', line 45
def get(args)
options = {}
params = {}
optparse = Morpheus::Cli::OptionParser.new do |opts|
opts.banner = subcommand_usage()
build_common_options(opts, options, [:remote, :quiet])
opts. = "Print your current authentication info.\n" +
"This contains tokens that should be kept secret, be careful."
end
optparse.parse!(args)
if args.count != 0
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
end
connect_result = connect(options)
return connect_result if (connect_result.is_a?(Numeric) && connect_result != 0)
print_h1 "Morpheus Credentials", [], options
description_cols = {
"Remote" => lambda {|wallet| @appliance_name },
"Username" => lambda {|wallet| wallet['username'] },
"Access Token" => lambda {|wallet| wallet['access_token'] },
"Refresh Token" => lambda {|wallet| wallet['refresh_token'] },
"Login Date" => lambda {|wallet| format_local_dt(wallet['login_date']) },
"Expire Date" => lambda {|wallet| wallet['expire_date'] ? format_local_dt(wallet['expire_date']) : "" },
}
print cyan
puts as_description_list(@wallet, description_cols)
print reset
return 0
end
|
#handle(args) ⇒ Object
41
42
43
|
# File 'lib/morpheus/cli/auth_command.rb', line 41
def handle(args)
handle_subcommand(args)
end
|
#login(args) ⇒ Object
these are all just aliases, heh
#login_test(args) ⇒ Object
86
87
88
|
# File 'lib/morpheus/cli/auth_command.rb', line 86
def login_test(args)
::Morpheus::Cli::Login.new.handle(['--test'] + args)
end
|
#print_access_token(args) ⇒ Object
#use_refresh_token(args) ⇒ Object