lib/mongo/auth/ldap/conversation.rb in mongo-2.1.0.beta vs lib/mongo/auth/ldap/conversation.rb in mongo-2.1.0.rc0
- old
+ new
@@ -23,11 +23,11 @@
class Conversation
# The login message.
#
# @since 2.0.0
- LOGIN = { authenticate: 1, digestPassword: false }.freeze
+ LOGIN = { saslStart: 1, autoAuthorize: 1 }.freeze
# @return [ Protocol::Reply ] reply The current reply in the
# conversation.
attr_reader :reply
@@ -61,11 +61,11 @@
# @since 2.0.0
def start
Protocol::Query.new(
Auth::EXTERNAL,
Database::COMMAND,
- LOGIN.merge(user: user.name, password: user.password, mechanism: LDAP::MECHANISM),
+ LOGIN.merge(payload: payload, mechanism: LDAP::MECHANISM),
limit: -1
)
end
# Create the new conversation.
@@ -79,9 +79,13 @@
def initialize(user)
@user = user
end
private
+
+ def payload
+ BSON::Binary.new("\x00#{user.name}\x00#{user.password}")
+ end
def validate!(reply)
raise Unauthorized.new(user) if reply.documents[0]['ok'] != 1
@reply = reply
end