Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 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
Exemplo n.º 4
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