Class: Mongo::Auth::CR::Conversation Deprecated Private
- Inherits:
-
Mongo::Auth::ConversationBase
- Object
- Mongo::Auth::ConversationBase
- Mongo::Auth::CR::Conversation
- Defined in:
- lib/mongo/auth/cr/conversation.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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 around a single MONGODB-CR conversation between the client and server.
Constant Summary collapse
- LOGIN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The login message base.
{ authenticate: 1 }.freeze
Instance Attribute Summary collapse
-
#database ⇒ String
readonly
private
Database The database to authenticate against.
-
#nonce ⇒ String
readonly
private
Nonce The initial auth nonce.
Attributes inherited from Mongo::Auth::ConversationBase
Instance Method Summary collapse
-
#continue(reply_document, connection) ⇒ Protocol::Query
private
Continue the CR conversation.
-
#start(connection) ⇒ Protocol::Query
private
Start the CR conversation.
Methods inherited from Mongo::Auth::ConversationBase
#initialize, #speculative_auth_document
Constructor Details
This class inherits a constructor from Mongo::Auth::ConversationBase
Instance Attribute Details
#database ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns database The database to authenticate against.
35 36 37 |
# File 'lib/mongo/auth/cr/conversation.rb', line 35 def database @database end |
#nonce ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns nonce The initial auth nonce.
38 39 40 |
# File 'lib/mongo/auth/cr/conversation.rb', line 38 def nonce @nonce end |
Instance Method Details
#continue(reply_document, connection) ⇒ Protocol::Query
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Continue the CR conversation. This sends the client final message to the server after setting the reply from the previous server communication.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mongo/auth/cr/conversation.rb', line 76 def continue(reply_document, connection) @nonce = reply_document[Auth::NONCE] if connection && connection.features.op_msg_enabled? selector = LOGIN.merge(user: user.name, nonce: nonce, key: user.auth_key(nonce)) selector[Protocol::Msg::DATABASE_IDENTIFIER] = user.auth_source cluster_time = connection.mongos? && connection.cluster_time selector[Operation::CLUSTER_TIME] = cluster_time if cluster_time Protocol::Msg.new([], {}, selector) else Protocol::Query.new( user.auth_source, Database::COMMAND, LOGIN.merge(user: user.name, nonce: nonce, key: user.auth_key(nonce)), limit: -1 ) end end |
#start(connection) ⇒ Protocol::Query
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Start the CR conversation. This returns the first message that needs to be sent to the server.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mongo/auth/cr/conversation.rb', line 49 def start(connection) if connection && connection.features.op_msg_enabled? selector = Auth::GET_NONCE.merge(Protocol::Msg::DATABASE_IDENTIFIER => user.auth_source) cluster_time = connection.mongos? && connection.cluster_time selector[Operation::CLUSTER_TIME] = cluster_time if cluster_time Protocol::Msg.new([], {}, selector) else Protocol::Query.new( user.auth_source, Database::COMMAND, Auth::GET_NONCE, limit: -1) end end |