Class: Mongo::Auth::Kerberos

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/auth/kerberos.rb,
lib/mongo/auth/kerberos/version.rb,
lib/mongo/auth/kerberos/conversation.rb,
lib/mongo/auth/kerberos/mri/authenticator.rb,
lib/mongo/auth/kerberos/jruby/authenticator.rb

Overview

Defines behaviour for Kerberos authentication.

Since:

  • 2.0.0

Defined Under Namespace

Classes: Authenticator, Conversation

Constant Summary collapse

MECHANISM =

The authentication mechanism string.

Since:

  • 2.0.0

'GSSAPI'.freeze
VERSION =

The gem version number.

Since:

  • 2.0.0

'2.1.0'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Kerberos

Instantiate a new authenticator.

example Create the authenticator.

Mongo::Auth::Kerberos.new(user)

Parameters:

  • user (Mongo::Auth::User)

    The user to authenticate.

Since:

  • 2.0.1



39
40
41
# File 'lib/mongo/auth/kerberos.rb', line 39

def initialize(user)
  @user = user
end

Instance Method Details

#login(connection) ⇒ Protocol::Reply

Log the user in on the given connection.

Examples:

Log the user in.

user.(connection)

Parameters:

  • connection (Mongo::Connection)

    The connection to log into. on.

Returns:

  • (Protocol::Reply)

    The authentication response.

Since:

  • 2.0.0



54
55
56
57
58
59
60
61
62
63
# File 'lib/mongo/auth/kerberos.rb', line 54

def (connection)
  conversation = Conversation.new(@user, connection.address.host)
  reply = connection.dispatch([ conversation.start ])
  connection.update_cluster_time(Operation::Result.new(reply))
  until reply.documents[0][Conversation::DONE]
    reply = connection.dispatch([ conversation.finalize(reply) ])
    connection.update_cluster_time(Operation::Result.new(reply))
  end
  reply
end