Class Mongo::Auth::SCRAM::Conversation
In: lib/mongo/auth/scram/conversation.rb
Parent: Object

Defines behavior around a single SCRAM-SHA-1/256 conversation between the client and server.

@since 2.0.0

Methods

continue   finalize   full_mechanism   id   new   start  

Constants

CLIENT_CONTINUE_MESSAGE = { saslContinue: 1 }.freeze   The base client continue message.

@since 2.0.0

CLIENT_FIRST_MESSAGE = { saslStart: 1, autoAuthorize: 1 }.freeze   The base client first message.

@since 2.0.0

CLIENT_KEY = 'Client Key'.freeze   The client key string.

@since 2.0.0

DONE = 'done'.freeze   The key for the done field in the responses.

@since 2.0.0

ID = 'conversationId'.freeze   The conversation id field.

@since 2.0.0

ITERATIONS = /i=(\d+)/.freeze   The iterations key in the responses.

@since 2.0.0

MIN_ITER_COUNT = 4096   The minimum iteration count for SCRAM-SHA-256.

@api private

@since 2.6.0

PAYLOAD = 'payload'.freeze   The payload field.

@since 2.0.0

RNONCE = /r=([^,]*)/.freeze   The rnonce key in the responses.

@since 2.0.0

SALT = /s=([^,]*)/.freeze   The salt key in the responses.

@since 2.0.0

SERVER_KEY = 'Server Key'.freeze   The server key string.

@since 2.0.0

VERIFIER = /v=([^,]*)/.freeze   The server signature verifier in the response.

@since 2.0.0

Attributes

nonce  [R]  @return [ String ] nonce The initial user nonce.
reply  [R]  @return [ Protocol::Message ] reply The current reply in the
  conversation.
user  [R]  @return [ User ] user The user for the conversation.

Public Class methods

Create the new conversation.

@example Create the new conversation.

  Conversation.new(user, mechanism)

@param [ Auth::User ] user The user to converse about. @param [ Symbol ] mechanism Authentication mechanism.

@since 2.0.0

Public Instance methods

Continue the SCRAM conversation. This sends the client final message to the server after setting the reply from the previous server communication.

@example Continue the conversation.

  conversation.continue(reply)

@param [ Protocol::Message ] reply The reply of the previous

  message.

@param [ Mongo::Server::Connection ] connection The connection being authenticated.

@return [ Protocol::Query ] The next message to send.

@since 2.0.0

Finalize the SCRAM conversation. This is meant to be iterated until the provided reply indicates the conversation is finished.

@example Finalize the conversation.

  conversation.finalize(reply)

@param [ Protocol::Message ] reply The reply of the previous

  message.

@param [ Mongo::Server::Connection ] connection The connection being authenticated.

@return [ Protocol::Query ] The next message to send.

@since 2.0.0

Get the id of the conversation.

@example Get the id of the conversation.

  conversation.id

@return [ Integer ] The conversation id.

@since 2.0.0

Start the SCRAM conversation. This returns the first message that needs to be sent to the server.

@example Start the conversation.

  conversation.start

@param [ Mongo::Server::Connection ] connection The connection being authenticated.

@return [ Protocol::Query ] The first SCRAM conversation message.

@since 2.0.0

[Validate]