code: def check_auth(self, all_credentials):
          
          if all_credentials or self.authset:
              cached = set(itervalues(all_credentials))
              authset = self.authset.copy()
  
              # Logout any credentials that no longer exist in the cache.
              for credentials in authset - cached:
                  auth.logout(credentials.source, self)
                  self.authset.discard(credentials)
  
              for credentials in cached - authset:
                  auth.authenticate(credentials, self)
                  self.authset.add(credentials)
docs: Update this socket's authentication.
  
          Log in or out to bring this socket's credentials up to date with
          those provided. Can raise ConnectionFailure or OperationFailure.
  
          :Parameters:
            - `all_credentials`: dict, maps auth source to MongoCredential.