Adds an auth_info hash to the SSH connection object (populated by password and publickey auth) to record the details of a successful authentication. Useful for querying which password or publickey was actually used to authenticate.
git-svn-id: file:///home/svn/framework3/trunk@9059 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
52d17d73da
commit
5dc72cf63d
|
@ -20,6 +20,11 @@ module Net
|
|||
case message.type
|
||||
when USERAUTH_SUCCESS
|
||||
debug { "password succeeded" }
|
||||
if session.options[:record_auth_info]
|
||||
session.auth_info[:method] = "password"
|
||||
session.auth_info[:user] = username
|
||||
session.auth_info[:password] = password
|
||||
end
|
||||
return true
|
||||
when USERAUTH_FAILURE
|
||||
debug { "password failed" }
|
||||
|
|
|
@ -67,7 +67,12 @@ module Net
|
|||
case message.type
|
||||
when USERAUTH_SUCCESS
|
||||
debug { "publickey succeeded (#{identity.fingerprint})" }
|
||||
return true
|
||||
if session.options[:record_auth_info]
|
||||
session.auth_info[:method] = "publickey"
|
||||
session.auth_info[:user] = username
|
||||
session.auth_info[:pubkey_id] = identity.fingerprint
|
||||
end
|
||||
return true
|
||||
when USERAUTH_FAILURE
|
||||
debug { "publickey failed (#{identity.fingerprint})" }
|
||||
return false
|
||||
|
|
|
@ -31,6 +31,9 @@ module Net; module SSH; module Authentication
|
|||
# a hash of options, given at construction time
|
||||
attr_reader :options
|
||||
|
||||
# when a successful auth is made, note the auth info if session.options[:record_auth_info]
|
||||
attr_accessor :auth_info
|
||||
|
||||
# Instantiates a new Authentication::Session object over the given
|
||||
# transport layer abstraction.
|
||||
def initialize(transport, options={})
|
||||
|
@ -41,6 +44,7 @@ module Net; module SSH; module Authentication
|
|||
@options = options
|
||||
|
||||
@allowed_auth_methods = @auth_methods
|
||||
@auth_info = {}
|
||||
end
|
||||
|
||||
# Attempts to authenticate the given user, in preparation for the next
|
||||
|
@ -131,4 +135,5 @@ module Net; module SSH; module Authentication
|
|||
Array(options[:key_data])
|
||||
end
|
||||
end
|
||||
end; end; end
|
||||
end; end; end
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ module Net; module SSH; module Connection
|
|||
# The list of callbacks for pending requests. See #send_global_request.
|
||||
attr_reader :pending_requests #:nodoc:
|
||||
|
||||
# when a successful auth is made, note the auth info if session.options[:record_auth_info]
|
||||
attr_accessor :auth_info
|
||||
|
||||
class NilChannel
|
||||
def initialize(session)
|
||||
@session = session
|
||||
|
|
Loading…
Reference in New Issue