Class: Mongo::Auth::CR Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/auth/cr.rb,
lib/mongo/auth/cr/conversation.rb

Overview

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.

Defines behavior for MongoDB-CR authentication.

Since:

  • 2.0.0

Defined Under Namespace

Classes: Conversation

Constant Summary collapse

MECHANISM =

The authentication mechinism string.

Since:

  • 2.0.0

'MONGODB-CR'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ CR

Instantiate a new authenticator.

Examples:

Create the authenticator.

Mongo::Auth::CR.new(user)

Parameters:

Since:

  • 2.0.0



44
45
46
# File 'lib/mongo/auth/cr.rb', line 44

def initialize(user)
  @user = user
end

Instance Attribute Details

#userMongo::Auth::User (readonly)

Returns The user to authenticate.

Returns:

Since:

  • 2.0.0



34
35
36
# File 'lib/mongo/auth/cr.rb', line 34

def user
  @user
end

Instance Method Details

#login(connection) ⇒ Protocol::Message

Log the user in on the given connection.

Examples:

Log the user in.

user.(connection)

Parameters:

  • connection (Mongo::Connection)

    The connection to log into.

Returns:

Since:

  • 2.0.0



58
59
60
61
62
63
64
65
# File 'lib/mongo/auth/cr.rb', line 58

def (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