docs: def gateway():
      """
      Authenticates single sign on session if ticket is available,
      but doesn't redirect to sign in url otherwise.
      """
  
      if settings.CAS_GATEWAY == False:
          raise ImproperlyConfigured('CAS_GATEWAY must be set to True')
  
      def wrap(func):
          def wrapped_f(*args):
  
              from cas.views import login
              request = args[0]
  
              try:
                  # use callable for pre-django 2.0
                  is_authenticated = request.user.is_authenticated()
              except TypeError:
                  is_authenticated = request.user.is_authenticated
  
              if is_authenticated:
                  # Is Authed, fine
                  pass
              else:
                  path_with_params = request.path + '?' + urlencode(request.GET.copy())
                  if request.GET.get('ticket'):
                      # Not Authed, but have a ticket!
                      # Try to authenticate
                      response = login(request, path_with_params, False, True)
                      if isinstance(response, HttpResponseRedirect):
                          # For certain instances where a forbidden occurs, we need to pass instead of return a response.
                          return response
                  else:
                      #Not Authed, but no ticket
                      gatewayed = request.GET.get('gatewayed')
                      if gatewayed == 'true':
                          pass
                      else:
                          # Not Authed, try to authenticate
                          response = login(request, path_with_params, False, True)
                          if isinstance(response, HttpResponseRedirect):
                              return response
  
              return func(*args)
          return wrapped_f
      return wrap