Class: Mongo::Auth::ConversationBase Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
Mongo::Auth::SaslConversationBase, Mongo::Auth::ScramConversationBase, Mongo::Auth::Aws::Conversation, Mongo::Auth::CR::Conversation, Mongo::Auth::Gssapi::Conversation, Mongo::Auth::LDAP::Conversation, Mongo::Auth::Scram256::Conversation, Mongo::Auth::Scram::Conversation, Mongo::Auth::X509::Conversation
|
|
Inherits: | Object |
Defined in: | lib/mongo/auth/conversation_base.rb |
Overview
Defines common behavior around authentication conversations between the client and the server.
Class Method Summary
-
.new(user, connection, **opts) ⇒ ConversationBase
constructor
Internal use only
Create the new conversation.
Instance Attribute Summary
- #connection ⇒ Mongo::Connection readonly Internal use only
- #user ⇒ Auth::User readonly Internal use only
Instance Method Summary
- #build_message(connection, auth_source, selector) ⇒ Protocol::Message Internal use only
-
#speculative_auth_document ⇒ Hash | nil
Internal use only
Returns the hash to provide to the server in the handshake as value of the speculativeAuthenticate key.
- #validate_external_auth_source Internal use only
Instance Attribute Details
#connection ⇒ Mongo::Connection
(readonly)
# File 'lib/mongo/auth/conversation_base.rb', line 41
attr_reader :connection
#user ⇒ Auth::User (readonly)
# File 'lib/mongo/auth/conversation_base.rb', line 38
attr_reader :user
Instance Method Details
#build_message(connection, auth_source, selector) ⇒ Protocol::Message
# File 'lib/mongo/auth/conversation_base.rb', line 55
def (connection, auth_source, selector) if connection && connection.features.op_msg_enabled? selector = selector.dup selector[Protocol::Msg::DATABASE_IDENTIFIER] = auth_source cluster_time = connection.mongos? && connection.cluster_time if cluster_time selector[Operation::CLUSTER_TIME] = cluster_time end Protocol::Msg.new([], {}, selector) else Protocol::Query.new( auth_source, Database::COMMAND, selector, limit: -1, ) end end
#speculative_auth_document ⇒ Hash
| nil
Returns the hash to provide to the server in the handshake as value of the speculativeAuthenticate key.
If the auth mechanism does not support speculative authentication, this method returns nil.
# File 'lib/mongo/auth/conversation_base.rb', line 50
def speculative_auth_document nil end
#validate_external_auth_source
# File 'lib/mongo/auth/conversation_base.rb', line 74
def validate_external_auth_source if user.auth_source != '$external' user_name_msg = if user.name " #{user.name}" else '' end mechanism = user.mechanism raise Auth::InvalidConfiguration, "User#{user_name_msg} specifies auth source '#{user.auth_source}', but the only valid auth source for #{mechanism} is '$external'" end end