class Mongo::Auth::X509
Defines behavior for X.509 authentication.
@since 2.0.0 @api private
Constants
- MECHANISM
The authentication mechinism string.
@since 2.0.0
Attributes
user[R]
@return [ Mongo::Auth::User
] The user to authenticate.
Public Class Methods
new(user)
click to toggle source
Instantiate a new authenticator.
@example Create the authenticator.
Mongo::Auth::X509.new(user)
@param [ Mongo::Auth::User
] user The user to authenticate.
@since 2.0.0
# File lib/mongo/auth/x509.rb, line 42 def initialize(user) # The only valid database for X.509 authentication is $external. if user.auth_source != '$external' user_name_msg = if user.name " #{user.name}" else '' end raise Auth::InvalidConfiguration, "User#{user_name_msg} specifies auth source '#{user.auth_source}', but the only valid auth source for X.509 is '$external'" end @user = user end
Public Instance Methods
login(connection)
click to toggle source
Log the user in on the given connection.
@example Log the user in.
user.login(connection)
@param [ Mongo::Connection ] connection The connection to log into.
on.
@return [ Protocol::Message
] The authentication response.
@since 2.0.0
# File lib/mongo/auth/x509.rb, line 67 def login(connection) conversation = Conversation.new(user) reply = connection.dispatch([ conversation.start(connection) ]) connection.update_cluster_time(Operation::Result.new(reply)) conversation.finalize(reply, connection) end