Class: Mongo::Auth::ConversationBase Private
- Inherits:
-
Object
- Object
- Mongo::Auth::ConversationBase
- 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.
Direct Known Subclasses
Mongo::Auth::CR::Conversation, LDAP::Conversation, SaslConversationBase, X509::Conversation
Instance Attribute Summary collapse
-
#connection ⇒ Mongo::Connection
readonly
private
The connection to authenticate over.
-
#user ⇒ Auth::User
readonly
private
User The user for the conversation.
Instance Method Summary collapse
-
#build_message(connection, auth_source, selector) ⇒ Protocol::Message
private
The message to send.
-
#initialize(user, connection, **_opts) ⇒ ConversationBase
constructor
private
Create the new conversation.
-
#speculative_auth_document ⇒ Hash | nil
private
Returns the hash to provide to the server in the handshake as value of the speculativeAuthenticate key.
- #validate_external_auth_source ⇒ Object private
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.
29 30 31 32 |
# File 'lib/mongo/auth/conversation_base.rb', line 29 def initialize(user, connection, **_opts) @user = user @connection = connection end |
Instance Attribute Details
#connection ⇒ Mongo::Connection (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 The connection to authenticate over.
38 39 40 |
# File 'lib/mongo/auth/conversation_base.rb', line 38 def connection @connection end |
#user ⇒ Auth::User (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 user The user for the conversation.
35 36 37 |
# File 'lib/mongo/auth/conversation_base.rb', line 35 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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mongo/auth/conversation_base.rb', line 52 def (connection, auth_source, selector) if connection selector = selector.dup selector[Protocol::Msg::DATABASE_IDENTIFIER] = 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_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.
47 48 49 |
# File 'lib/mongo/auth/conversation_base.rb', line 47 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.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mongo/auth/conversation_base.rb', line 69 def validate_external_auth_source return unless 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 |