class Mongo::Auth::SCRAM
Defines behavior for SCRAM
authentication.
@since 2.0.0 @api private
Constants
- MECHANISMS
Map the user-specified authentication mechanism to the proper names of the mechanisms.
@since 2.6.0
- SCRAM_SHA_1_MECHANISM
The authentication mechanism string for SCRAM-SHA-1.
@since 2.6.0
- SCRAM_SHA_256_MECHANISM
The authentication mechanism string for SCRAM-SHA-256.
@since 2.6.0
Attributes
user[R]
@return [ Mongo::Auth::User
] The user to authenticate.
Public Class Methods
new(user)
click to toggle source
Instantiate a new authenticator.
@example Create the authenticator.
Mongo::Auth::SCRAM.new(user)
@param [ Mongo::Auth::User
] user The user to authenticate.
@since 2.0.0
# File lib/mongo/auth/scram.rb, line 55 def initialize(user) @user = user end
Public Instance Methods
login(connection)
click to toggle source
Log the user in on the given connection.
@example Log the user in.
user.login(connection)
@param [ Mongo::Connection ] connection The connection to log into.
@return [ Protocol::Message
] The authentication response.
@since 2.0.0
# File lib/mongo/auth/scram.rb, line 69 def login(connection) mechanism = user.mechanism || :scram conversation = Conversation.new(user, mechanism) reply = connection.dispatch([ conversation.start(connection) ]) connection.update_cluster_time(Operation::Result.new(reply)) reply = connection.dispatch([ conversation.continue(reply, connection) ]) connection.update_cluster_time(Operation::Result.new(reply)) until reply.documents[0][Conversation::DONE] reply = connection.dispatch([ conversation.finalize(reply, connection) ]) connection.update_cluster_time(Operation::Result.new(reply)) end reply end