Ejemplo n.º 1
0
    def __init__(self, **kwargs):
        """
        meta - META dictionary from the request object
        ip4 - request ip4
        """
        if "meta" in kwargs:
            request_meta = kwargs["meta"]
            del kwargs["meta"]
        super(Affinity, self).__init__(**kwargs)

        self.cookie_expiry = structure.AFFINITY_EXPIRY
        self.cookie_domain = structure.machine.to_cookie_domain(
            request_meta.get("HTTP_HOST", structure.machine.DOMAINS[0])
        )
        self.base_domain = structure.get_base_domain(request_meta)
Ejemplo n.º 2
0
    def __init__(self, request_meta, identity, encoded=None):
        self.identity = identity
        self.cookie_expiry = structure.AFFINITY_EXPIRY
        self.cookie_domain = structure.machine.to_cookie_domain(
            request_meta.get("HTTP_HOST", structure.machine.DOMAINS[0])
        )
        self.base_domain = structure.get_base_domain(request_meta)
        if encoded:
            self._decode(encoded)
            self.generated = False
        else:
            self._generate()
            self.generated = True
        import secrets

        self.secret = secrets.VERIFICATION_SECRET[self.identity.number][0]