How to use the itsdangerous.Serializer function in itsdangerous

To help you get started, we’ve selected a few itsdangerous examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pallets / itsdangerous / tests / test_itsdangerous.py View on Github external
def test_decode_with_timeout(self):
        secret_key = "predictable-key"
        value = u"hello"

        s = self.make_serializer(secret_key)
        ts = s.dumps(value)
        self.assertNotEqual(ts, itsdangerous.Serializer(secret_key).dumps(value))

        self.assertEqual(s.loads(ts), value)
        time.time = lambda: 10
        self.assertEqual(s.loads(ts, max_age=11), value)
        self.assertEqual(s.loads(ts, max_age=10), value)
        self.assertRaises(itsdangerous.SignatureExpired, s.loads, ts, max_age=9)
github abilian / abilian-sbe / abilian / sbe / apps / forum / tasks.py View on Github external
def build_local_part(name, uid):
    """Build local part as 'name-uid-digest', ensuring length < 64."""
    key = current_app.config["SECRET_KEY"]
    serializer = Serializer(key)
    signature = serializer.dumps(uid)
    digest = md5(signature)
    local_part = name + "+" + uid + "-" + digest

    if len(local_part) > 64:
        if (len(local_part) - len(digest) - 1) > 64:
            # even without digest, it's too long
            raise ValueError(
                "Cannot build reply address: local part exceeds 64 characters"
            )
        local_part = local_part[:64]

    return local_part
github fossasia / open-event-server / app / vintage / helpers / helpers.py View on Github external
def get_serializer(secret_key='secret_key'):
    return Serializer(secret_key)
github fossasia / open-event-server / app / helpers / helpers.py View on Github external
def get_serializer(secret_key=None):
    return Serializer('secret_key')
github fossasia / open-event-server / app / api / helpers / utilities.py View on Github external
def get_serializer(secret_key='secret_key'):
    return Serializer(secret_key)