Пример #1
0
    def getXsrfToken(cls, path=None, method="POST", data=None, site=None, **extra):
        """Returns an XSRF token for request context.

    It is signed by Melange XSRF middleware.
    Add this token to POST data in order to pass the validation check of
    Melange XSRF middleware for HTTP POST.
    """

        # TODO(nathaniel): What? Commented-out code?
        """
    request = HttpRequest()
    request.path = path
    request.method = method
    """
        # request is currently not used in _getSecretKey
        class SiteContainingRequest(object):
            def __init__(self, site):
                if site:
                    self.site = site

        request = SiteContainingRequest(site)
        # TODO(nathaniel): module API violation.
        key = xsrf_middleware._GetSecretKey(request)
        user_id = xsrfutil._getCurrentUserId()
        xsrf_token = xsrfutil._generateToken(key, user_id)
        return xsrf_token
Пример #2
0
    def getXsrfToken(cls,
                     path=None,
                     method='POST',
                     data={},
                     site=None,
                     **extra):
        """Returns an XSRF token for request context.

    It is signed by Melange XSRF middleware.
    Add this token to POST data in order to pass the validation check of
    Melange XSRF middleware for HTTP POST.
    """
        """
    request = HttpRequest()
    request.path = path
    request.method = method
    """

        # request is currently not used in _getSecretKey
        class SiteContainingRequest(object):
            def __init__(self, site):
                if site:
                    self.site = site

        request = SiteContainingRequest(site)
        xsrf = XsrfMiddleware()
        key = xsrf._getSecretKey(request)
        user_id = xsrfutil._getCurrentUserId()
        xsrf_token = xsrfutil._generateToken(key, user_id)
        return xsrf_token
Пример #3
0
 def getXsrfToken(self):
     """Returns an XSRF token for POST requests.
 """
     request = None
     xsrf = XsrfMiddleware()
     key = xsrf._getSecretKey(request)
     user_id = xsrfutil._getCurrentUserId()
     xsrf_token = xsrfutil._generateToken(key, user_id)
     return xsrf_token
Пример #4
0
 def getXsrfToken(self):
   """Returns an XSRF token for POST requests.
   """
   request = None
   xsrf = XsrfMiddleware()
   key = xsrf._getSecretKey(request)
   user_id = xsrfutil._getCurrentUserId()
   xsrf_token = xsrfutil._generateToken(key, user_id)
   return xsrf_token
Пример #5
0
  def getXsrfToken(cls, path=None, method='POST', data={}, **extra):
    """Returns an XSRF token for request context.

    It is signed by Melange XSRF middleware.
    Add this token to POST data in order to pass the validation check of
    Melange XSRF middleware for HTTP POST.
    """

    """
    request = HttpRequest()
    request.path = path
    request.method = method
    """
    # request is currently not used in _getSecretKey
    request = None
    xsrf = XsrfMiddleware()
    key = xsrf._getSecretKey(request)
    user_id = xsrfutil._getCurrentUserId()
    xsrf_token = xsrfutil._generateToken(key, user_id)
    return xsrf_token