Class: Mongo::Auth::Kerberos::Conversation

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

Overview

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

Since:

  • 2.0.0

Constant Summary collapse

CONTINUE_MESSAGE =

The base client continue message.

Since:

  • 2.0.0

{ saslContinue: 1 }.freeze
DONE =

The key for the done field in the responses.

Since:

  • 2.0.0

'done'.freeze
ID =

The conversation id field.

Since:

  • 2.0.0

'conversationId'.freeze
PAYLOAD =

The payload field.

Since:

  • 2.0.0

'payload'.freeze
START_MESSAGE =

The base client first message.

Since:

  • 2.0.0

{ saslStart: 1, autoAuthorize: 1 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, host) ⇒ Conversation

Create the new conversation.

Examples:

Create the new conversation.

Conversation.new(user, 'test.example.com')

Since:

  • 2.0.0


123
124
125
126
# File 'lib/mongo/auth/kerberos/conversation.rb', line 123

def initialize(user, host)
  @user = user
  @authenticator = Authenticator.new(user, host)
end

Instance Attribute Details

#authenticatorAuthenticator (readonly)

Returns authenticator The native SASL authenticator.

Since:

  • 2.0.0


60
61
62
# File 'lib/mongo/auth/kerberos/conversation.rb', line 60

def authenticator
  @authenticator
end

#replyProtocol::Reply (readonly)

Returns reply The current reply in the conversation.

Since:

  • 2.0.0


57
58
59
# File 'lib/mongo/auth/kerberos/conversation.rb', line 57

def reply
  @reply
end

#userMongo::Auth::User (readonly)

Returns user The user to authenticate.

Since:

  • 2.0.0


63
64
65
# File 'lib/mongo/auth/kerberos/conversation.rb', line 63

def user
  @user
end

Instance Method Details

#finalize(reply) ⇒ Protocol::Query

Finalize the conversation.

Examples:

Finalize the conversation.

conversation.finalize(reply)

Since:

  • 2.0.0


75
76
77
78
79
80
81
82
83
# File 'lib/mongo/auth/kerberos/conversation.rb', line 75

def finalize(reply)
  validate!(reply)
  Protocol::Query.new(
    Auth::EXTERNAL,
    Database::COMMAND,
    CONTINUE_MESSAGE.merge(payload: continue_token, conversationId: id),
    limit: -1
  )
end

#idInteger

Get the id of the conversation.

Examples:

Get the id of the conversation.

conversation.id

Since:

  • 2.0.0


110
111
112
# File 'lib/mongo/auth/kerberos/conversation.rb', line 110

def id
  reply.documents[0][ID]
end

#startProtocol::Query

Start the authentication conversation.

Examples:

Start the conversation.

conversation.start

Since:

  • 2.0.0


93
94
95
96
97
98
99
100
# File 'lib/mongo/auth/kerberos/conversation.rb', line 93

def start
  Protocol::Query.new(
    Auth::EXTERNAL,
    Database::COMMAND,
    START_MESSAGE.merge(mechanism: Kerberos::MECHANISM, payload: start_token),
    limit: -1
  )
end