Ejemplo n.º 1
0
def get_storage_value(user_signature, filter_name, default_value=None):
    storage_value = default_value
    if user_signature and user_signature in request.cookies:
        cookie = json.loads(request.get_cookie(user_signature,
                                               default={},
                                               secret=settings.SESSION_SECRET_KEY))
        storage_value = cookie.get(filter_name, default_value)

    return storage_value
Ejemplo n.º 2
0
 def _get_key(self):
     if self.csrf_session is not None:
         key = self.csrf_session.get("_form_key")
         if key is None:
             key = str(uuid.uuid1())
             self.csrf_session["_form_key"] = key
     else:
         key = request.get_cookie("_form_key")
         if key is None:
             key = str(uuid.uuid1())
             response.set_cookie("_form_key", key, same_site="Strict")
     additional_info = {
         "signing_info": self.signing_info,
         "form_name": self.form_name,
     }
     return key + "." + json.dumps(additional_info)
Ejemplo n.º 3
0
 def _get_key(self):
     if self.csrf_session is not None:
         key = self.csrf_session.get("_formkey")
     else:
         key = request.get_cookie("_formkey")
     return key