'The username passed as ``remote_user`` is considered trusted. Return
the ``User`` object with the given username. Create a new ``User``
object if ``create_unknown_user`` is ``True``.
Return None if ``create_unknown_user`` is ``False`` and a ``User``
object with the given username is not found in the database.'

def authenticate(self, request, remote_user):

    if (not remote_user):
        return
    user = None
    username = self.clean_username(remote_user)
    if self.create_unknown_user:
        (user, created) = UserModel._default_manager.get_or_create(**{UserModel.USERNAME_FIELD: username})
        if created:
            user = self.configure_user(user)
    else:
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            pass
    return (user if self.user_can_authenticate(user) else None)
