Add signature for Django 3.2 TimestampSigner (#751)

Django 3.2 introduced two new methods: `sign_object` and
`unsign_object` which can sign/unsign "complex data structures" such as
lists, tuples, dictionaries:

https://docs.djangoproject.com/en/3.2/topics/signing/#django.core.signing.TimestampSigner

Because the methods take an arbitrary serializer (a JSON serializer by
default, but not guaranteed), we cannot be sure of the type of `obj`.
This commit is contained in:
David Cain
2021-11-13 11:56:27 -08:00
committed by GitHub
parent b5c20100ff
commit 331042d1c7

View File

@@ -51,3 +51,15 @@ class Signer:
class TimestampSigner(Signer):
def timestamp(self) -> str: ...
def unsign(self, value: str, max_age: Optional[Union[int, timedelta]] = ...) -> str: ...
def sign_object(
self,
obj: Any,
serializer: Type[Serializer] = ...,
compress: bool = ...,
) -> str: ...
def unsign_object(
self,
signed_obj: str,
serializer: Type[Serializer] = ...,
max_age: Optional[Union[int, timedelta]] = ...,
) -> Any: ...