Class: Mongo::Auth::X509::Conversation

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/auth/x509/conversation.rb

Overview

Defines behaviour around a single x.509 conversation between the client and server.

Since:

  • 2.0.0

Constant Summary

LOGIN =

The login message.

Since:

  • 2.0.0

{ authenticate: 1 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Conversation

Create the new conversation.

Examples:

Create the new conversation.

Conversation.new(user, "admin")

Parameters:

  • user (Auth::User)

    The user to converse about.

Since:

  • 2.0.0



81
82
83
# File 'lib/mongo/auth/x509/conversation.rb', line 81

def initialize(user)
  @user = user
end

Instance Attribute Details

#replyProtocol::Reply (readonly)

Returns reply The current reply in the conversation.

Returns:

Since:

  • 2.0.0



32
33
34
# File 'lib/mongo/auth/x509/conversation.rb', line 32

def reply
  @reply
end

#userUser (readonly)

Returns user The user for the conversation.

Returns:

  • (User)

    user The user for the conversation.

Since:

  • 2.0.0



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.

Examples:

Finalize the conversation.

conversation.finalize(reply)

Parameters:

Returns:

Since:

  • 2.0.0



49
50
51
# File 'lib/mongo/auth/x509/conversation.rb', line 49

def finalize(reply)
  validate!(reply)
end

#startProtocol::Query

Start the x.509 conversation. This returns the first message that needs to be send to the server.

Examples:

Start the conversation.

conversation.start

Returns:

Since:

  • 2.0.0



62
63
64
65
66
67
68
69
70
71
# File 'lib/mongo/auth/x509/conversation.rb', line 62

def start
   = LOGIN.merge(mechanism: X509::MECHANISM)
  [:user] = user.name if user.name
  Protocol::Query.new(
    Auth::EXTERNAL,
    Database::COMMAND,
    ,
    limit: -1
  )
end