Class: Mongo::Auth::SCRAM
- Inherits:
-
Object
- Object
- Mongo::Auth::SCRAM
- Defined in:
- lib/mongo/auth/scram.rb,
lib/mongo/auth/scram/conversation.rb
Overview
Defines behaviour for SCRAM-SHA1 authentication.
Defined Under Namespace
Classes: Conversation
Constant Summary collapse
- MECHANISM =
The authentication mechinism string.
'SCRAM-SHA-1'.freeze
Instance Attribute Summary collapse
-
#user ⇒ Mongo::Auth::User
readonly
The user to authenticate.
Instance Method Summary collapse
-
#initialize(user) ⇒ SCRAM
constructor
Instantiate a new authenticator.
-
#login(connection) ⇒ Protocol::Reply
Log the user in on the given connection.
Constructor Details
#initialize(user) ⇒ SCRAM
Instantiate a new authenticator.
41 42 43 |
# File 'lib/mongo/auth/scram.rb', line 41 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Mongo::Auth::User (readonly)
Returns The user to authenticate.
31 32 33 |
# File 'lib/mongo/auth/scram.rb', line 31 def user @user end |
Instance Method Details
#login(connection) ⇒ Protocol::Reply
Log the user in on the given connection.
56 57 58 59 60 61 62 63 64 |
# File 'lib/mongo/auth/scram.rb', line 56 def login(connection) conversation = Conversation.new(user) reply = connection.dispatch([ conversation.start ]) reply = connection.dispatch([ conversation.continue(reply) ]) until reply.documents[0][Conversation::DONE] reply = connection.dispatch([ conversation.finalize(reply) ]) end reply end |