class Mongo::Auth::CR

Defines behavior for MongoDB-CR authentication.

@since 2.0.0 @deprecated MONGODB-CR authentication mechanism is deprecated

as of MongoDB 3.6. Support for it in the Ruby driver will be
removed in driver version 3.0. Please use SCRAM instead.

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::CR.new(user)

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

@since 2.0.0

# File lib/mongo/auth/cr.rb, line 44
def initialize(user)
  @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.

@return [ Protocol::Message ] The authentication response.

@since 2.0.0

# File lib/mongo/auth/cr.rb, line 58
def login(connection)
  conversation = Conversation.new(user)
  reply = connection.dispatch([ conversation.start(connection) ])
  connection.update_cluster_time(Operation::Result.new(reply))
  reply = connection.dispatch([ conversation.continue(reply, connection) ])
  connection.update_cluster_time(Operation::Result.new(reply))
  conversation.finalize(reply, connection)
end