ConversationBase — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Auth::ConversationBasePrivate

Inherits:

Object

Defined in:

lib/mongo/auth/conversation_base.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.

Defines common behavior around authentication conversations between the client and the server.

Instance Attribute Summary collapse

Instance Method Summarycollapse

Constructor Details

#initialize(user, connection, **opts) ⇒ ConversationBase

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.

Create the new conversation.

32 33 34 35 # File 'lib/mongo/auth/conversation_base.rb', line 32 def initialize(user, connection, **opts) @user = user @connection = connection end

Instance Attribute Details

#connection ⇒ Mongo::Connection

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 The connection to authenticate over.

41 42 43 # File 'lib/mongo/auth/conversation_base.rb', line 41 def connection @connection end

#userAuth::User

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 user The user for the conversation.

38 39 40 # File 'lib/mongo/auth/conversation_base.rb', line 38 def user @user end

Instance Method Details

#build_message(connection, auth_source, selector) ⇒ Protocol::Message

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 The message to send.

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 # File 'lib/mongo/auth/conversation_base.rb', line 55 def build_message(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

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 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.

50 51 52 # File 'lib/mongo/auth/conversation_base.rb', line 50 def speculative_auth_document nil end

#validate_external_auth_source ⇒ Object

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.

74 75 76 77 78 79 80 81 82 83 84 # 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