Class: Mongo::Auth::X509::Conversation
- Inherits:
-
Object
- Object
- Mongo::Auth::X509::Conversation
- Defined in:
- lib/mongo/auth/x509/conversation.rb
Overview
Defines behavior around a single x.509 conversation between the client and server.
Constant Summary collapse
- LOGIN =
The login message.
{ authenticate: 1 }.freeze
Instance Attribute Summary collapse
-
#reply ⇒ Protocol::Message
readonly
Reply The current reply in the conversation.
-
#user ⇒ User
readonly
User The user for the conversation.
Instance Method Summary collapse
-
#finalize(reply) ⇒ Protocol::Query
Finalize the x.509 conversation.
-
#initialize(user) ⇒ Conversation
constructor
Create the new conversation.
-
#start(connection = nil) ⇒ Protocol::Query
Start the x.509 conversation.
Constructor Details
#initialize(user) ⇒ Conversation
Create the new conversation.
91 92 93 |
# File 'lib/mongo/auth/x509/conversation.rb', line 91 def initialize(user) @user = user end |
Instance Attribute Details
#reply ⇒ Protocol::Message (readonly)
Returns reply The current reply in the conversation.
32 33 34 |
# File 'lib/mongo/auth/x509/conversation.rb', line 32 def reply @reply end |
#user ⇒ User (readonly)
Returns user The user for the conversation.
35 36 37 |
# File 'lib/mongo/auth/x509/conversation.rb', line 35 def user @user end |
Instance Method Details
#finalize(reply) ⇒ Protocol::Query
Finalize the x.509 conversation. This is meant to be iterated until the provided reply indicates the conversation is finished.
49 50 51 |
# File 'lib/mongo/auth/x509/conversation.rb', line 49 def finalize(reply) validate!(reply) end |
#start(connection = nil) ⇒ Protocol::Query
Start the x.509 conversation. This returns the first message that needs to be send to the server.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/mongo/auth/x509/conversation.rb', line 64 def start(connection = nil) login = LOGIN.merge(mechanism: X509::MECHANISM) login[:user] = user.name if user.name if connection && connection.features.op_msg_enabled? selector = login 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( Auth::EXTERNAL, Database::COMMAND, login, limit: -1 ) end end |