(self)
return authenticated
Authenticate to the database.

        Available mechanisms:
        * Username & password
        * X.509

        More information:
        https://api.mongodb.com/python/current/examples/authentication.html
Authenticate to the database.
Authenticate to the database .
def _authenticate(self):
        """
        Authenticate to the database.

        Available mechanisms:
        * Username & password
        * X.509

        More information:
        https://api.mongodb.com/python/current/examples/authentication.html
        """
        authenticated = False
        database = self[self._config.auth_source]
        username = self._config.username
        try:
            # X.509
            if self._config.use_x509 and username:
                self._log.debug(u"Authenticate `%s` to `%s` using `MONGODB-X509` mechanism", username, database)
                authenticated = database.authenticate(username, mechanism='MONGODB-X509')
            elif self._config.use_x509:
                self._log.debug(u"Authenticate to `%s` using `MONGODB-X509` mechanism", database)
                authenticated = database.authenticate(mechanism='MONGODB-X509')
            # Username & password
            else:
                authenticated = database.authenticate(username, self._config.password)

        except PyMongoError as e:
            self._log.error(u"Authentication failed due to invalid credentials or configuration issues. %s", e)

        return authenticated
def _authenticate ( self ) : authenticated = False database = self [ self . _config . auth_source ] username = self . _config . username try : # X.509 if self . _config . use_x509 and username : self . _log . debug ( u"Authenticate `%s` to `%s` using `MONGODB-X509` mechanism" , username , database ) authenticated = database . authenticate ( username , mechanism = 'MONGODB-X509' ) elif self . _config . use_x509 : self . _log . debug ( u"Authenticate to `%s` using `MONGODB-X509` mechanism" , database ) authenticated = database . authenticate ( mechanism = 'MONGODB-X509' ) # Username & password else : authenticated = database . authenticate ( username , self . _config . password ) except PyMongoError as e : self . _log . error ( u"Authentication failed due to invalid credentials or configuration issues. %s" , e ) return authenticated