Class: HrrRbSsh::Authentication::Method::KeyboardInteractive
- Inherits:
-
HrrRbSsh::Authentication::Method
- Object
- HrrRbSsh::Authentication::Method
- HrrRbSsh::Authentication::Method::KeyboardInteractive
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb
Defined Under Namespace
Classes: Context, InfoRequest, InfoResponse
Constant Summary collapse
- NAME =
'keyboard-interactive'
- PREFERENCE =
30
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
- #authenticate(userauth_request_message) ⇒ Object
-
#initialize(transport, options, variables, authentication_methods, logger: nil) ⇒ KeyboardInteractive
constructor
A new instance of KeyboardInteractive.
- #request_authentication(username, service_name) ⇒ Object
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Methods included from SubclassWithPreferenceListable
#[], #inherited, #list_preferred, #list_supported
Constructor Details
#initialize(transport, options, variables, authentication_methods, logger: nil) ⇒ KeyboardInteractive
Returns a new instance of KeyboardInteractive.
15 16 17 18 19 20 21 22 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 15 def initialize transport, , variables, authentication_methods, logger: nil self.logger = logger @transport = transport @options = @authenticator = .fetch( 'authentication_keyboard_interactive_authenticator', Authenticator.new{ false } ) @variables = variables @authentication_methods = authentication_methods end |
Instance Method Details
#authenticate(userauth_request_message) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 24 def authenticate log_info { "authenticate" } log_debug { "userauth request: " + .inspect } username = [:'user name'] submethods = [:'submethods'] context = Context.new(@transport, username, submethods, @variables, @authentication_methods, logger: logger) @authenticator.authenticate context end |
#request_authentication(username, service_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 33 def request_authentication username, service_name = { :'message number' => Message::SSH_MSG_USERAUTH_REQUEST::VALUE, :"user name" => username, :"service name" => service_name, :"method name" => NAME, :"language tag" => "", :'submethods' => "", } payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode @transport.send payload payload = @transport.receive case payload[0,1].unpack("C")[0] when Message::SSH_MSG_USERAUTH_INFO_REQUEST::VALUE = Message::SSH_MSG_USERAUTH_INFO_REQUEST.new(logger: logger).decode payload num_responses = @options['client_authentication_keyboard_interactive'].size = { :'message number' => Message::SSH_MSG_USERAUTH_INFO_RESPONSE::VALUE, :'num-responses' => num_responses, } = @options['client_authentication_keyboard_interactive'].map.with_index{ |response, i| {:"response[#{i+1}]" => response} }.inject(Hash.new){ |a, b| a.merge(b) } .update() payload = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.new(logger: logger).encode @transport.send payload @transport.receive else payload end end |