class Mongo::Auth::X509

Defines behavior for X.509 authentication.

@since 2.0.0 @api private

Constants

MECHANISM

The authentication mechanism string.

@since 2.0.0

Public Class Methods

new(user, connection, **opts) click to toggle source

Initializes the X.509 authenticator.

@param [ Auth::User ] user The user to authenticate. @param [ Mongo::Connection ] connection The connection to authenticate over.

Calls superclass method Mongo::Auth::Base::new
# File lib/mongo/auth/x509.rb, line 36
def initialize(user, connection, **opts)
  # 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

  super
end

Public Instance Methods

login() click to toggle source

Log the user in on the current connection.

@return [ BSON::Document ] The document of the authentication response.

# File lib/mongo/auth/x509.rb, line 53
def login
  converse_1_step(connection, conversation)
end