Class: Mongo::Auth::SCRAM Private
- Inherits:
-
Object
- Object
- Mongo::Auth::SCRAM
- Defined in:
- lib/mongo/auth/scram.rb,
lib/mongo/auth/scram/conversation.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defines behavior for SCRAM authentication.
Defined Under Namespace
Classes: Conversation
Constant Summary collapse
- SCRAM_SHA_1_MECHANISM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The authentication mechanism string for SCRAM-SHA-1.
'SCRAM-SHA-1'.freeze
- SCRAM_SHA_256_MECHANISM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The authentication mechanism string for SCRAM-SHA-256.
'SCRAM-SHA-256'.freeze
- MECHANISMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Map the user-specified authentication mechanism to the proper names of the mechanisms.
{ scram: SCRAM_SHA_1_MECHANISM, scram256: SCRAM_SHA_256_MECHANISM }.freeze
Instance Attribute Summary collapse
-
#user ⇒ Mongo::Auth::User
readonly
private
The user to authenticate.
Instance Method Summary collapse
-
#initialize(user) ⇒ SCRAM
constructor
private
Instantiate a new authenticator.
-
#login(connection) ⇒ Protocol::Message
private
Log the user in on the given connection.
Constructor Details
#initialize(user) ⇒ SCRAM
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiate a new authenticator.
55 56 57 |
# File 'lib/mongo/auth/scram.rb', line 55 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Mongo::Auth::User (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The user to authenticate.
45 46 47 |
# File 'lib/mongo/auth/scram.rb', line 45 def user @user end |
Instance Method Details
#login(connection) ⇒ Protocol::Message
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Log the user in on the given connection.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# 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 |