docs: def do_logout_service(request, data, binding, config_loader_path=None, next_page=None,
                     logout_error_template='djangosaml2/logout_error.html'):
      """SAML Logout Response endpoint
  
      The IdP will send the logout response to this view,
      which will process it with pysaml2 help and log the user
      out.
      Note that the IdP can request a logout even when
      we didn't initiate the process as a single logout
      request started by another SP.
      """
      logger.debug('Logout service started')
      conf = get_config(config_loader_path, request)
  
      state = StateCache(request.session)
      client = Saml2Client(conf, state_cache=state,
                           identity_cache=IdentityCache(request.session))
  
      if 'SAMLResponse' in data:  # we started the logout
          logger.debug('Receiving a logout response from the IdP')
          response = client.parse_logout_request_response(data['SAMLResponse'], binding)
          state.sync()
          return finish_logout(request, response, next_page=next_page)
  
      elif 'SAMLRequest' in data:  # logout started by the IdP
          logger.debug('Receiving a logout request from the IdP')
          subject_id = _get_subject_id(request.session)
          if subject_id is None:
              logger.warning(
                  'The session does not contain the subject id for user %s. Performing local logout',
                  request.user)
              auth.logout(request)
              return render(request, logout_error_template, status=403)
          else:
              http_info = client.handle_logout_request(
                  data['SAMLRequest'],
                  subject_id,
                  binding,
                  relay_state=data.get('RelayState', ''))
              state.sync()
              auth.logout(request)
              return HttpResponseRedirect(get_location(http_info))
      else:
          logger.error('No SAMLResponse or SAMLRequest parameter found')
          raise Http404('No SAMLResponse or SAMLRequest parameter found')