module Mongo::Auth
This namespace contains all authentication related behavior.
@since 2.0.0
Constants
- EXTERNAL
The external database name.
@since 2.0.0 @api private
- GET_NONCE
Constant for the nonce command.
@since 2.0.0 @api private
- NONCE
Constant for the nonce field.
@since 2.0.0 @api private
- SOURCES
Map the symbols parsed from the
URI
connection string to strategies.@note This map is not frozen because when mongo_kerberos is loaded,
it mutates this map by adding the Kerberos authenticator.
@since 2.0.0
Public Instance Methods
Get an authenticator for the provided user to authenticate over the provided connection.
@param [ Auth::User
] user The user to authenticate. @param [ Mongo::Connection ] connection The connection to authenticate over.
@option opts [ String | nil ] speculative_auth_client_nonce The client
nonce used in speculative auth on the specified connection that produced the specified speculative auth result.
@option opts [ BSON::Document | nil ] speculative_auth_result The
value of speculativeAuthenticate field of ismaster response of the handshake on the specified connection.
@return [ Auth::Aws
| Auth::CR
| Auth::Gssapi
| Auth::LDAP
|
Auth::Scram | Auth::Scram256 | Auth::X509 ] The authenticator.
@since 2.0.0 @api private
# File lib/mongo/auth.rb, line 91 def get(user, connection, **opts) mechanism = user.mechanism raise InvalidMechanism.new(mechanism) if !SOURCES.has_key?(mechanism) SOURCES[mechanism].new(user, connection, **opts) end