Class: Mongo::Auth::CR::Conversation
- Inherits:
-
Object
- Object
- Mongo::Auth::CR::Conversation
- Defined in:
- lib/mongo/auth/cr/conversation.rb
Overview
Defines behaviour around a single MONGODB-CR conversation between the client and server.
Constant Summary collapse
- LOGIN =
The login message base.
{ authenticate: 1 }.freeze
Instance Attribute Summary collapse
-
#database ⇒ String
readonly
Database The database to authenticate against.
-
#nonce ⇒ String
readonly
Nonce The initial auth nonce.
-
#reply ⇒ Protocol::Reply
readonly
Reply The current reply in the conversation.
-
#user ⇒ User
readonly
User The user for the conversation.
Instance Method Summary collapse
-
#continue(reply) ⇒ Protocol::Query
Continue the CR conversation.
-
#finalize(reply) ⇒ Protocol::Query
Finalize the CR conversation.
-
#initialize(user) ⇒ Conversation
constructor
Create the new conversation.
-
#start ⇒ Protocol::Query
Start the CR conversation.
Constructor Details
#initialize(user) ⇒ Conversation
Create the new conversation.
107 108 109 |
# File 'lib/mongo/auth/cr/conversation.rb', line 107 def initialize(user) @user = user end |
Instance Attribute Details
#database ⇒ String (readonly)
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)
Returns nonce The initial auth nonce.
38 39 40 |
# File 'lib/mongo/auth/cr/conversation.rb', line 38 def nonce @nonce end |
#reply ⇒ Protocol::Reply (readonly)
Returns reply The current reply in the conversation.
32 33 34 |
# File 'lib/mongo/auth/cr/conversation.rb', line 32 def reply @reply end |
#user ⇒ User (readonly)
Returns user The user for the conversation.
41 42 43 |
# File 'lib/mongo/auth/cr/conversation.rb', line 41 def user @user end |
Instance Method Details
#continue(reply) ⇒ Protocol::Query
Continue the CR conversation. This sends the client final message to the server after setting the reply from the previous server communication.
56 57 58 59 60 61 62 63 64 |
# File 'lib/mongo/auth/cr/conversation.rb', line 56 def continue(reply) validate!(reply) Protocol::Query.new( user.auth_source, Database::COMMAND, LOGIN.merge(user: user.name, nonce: nonce, key: user.auth_key(nonce)), limit: -1 ) end |
#finalize(reply) ⇒ Protocol::Query
Finalize the CR conversation. This is meant to be iterated until the provided reply indicates the conversation is finished.
78 79 80 |
# File 'lib/mongo/auth/cr/conversation.rb', line 78 def finalize(reply) validate!(reply) end |