Closed akx closed 1 year ago
Alternatively, this could be implemented as well by passing a callable
def decode(
self,
jwt: str,
...
# hook for custom payload decompression
decompress_payload: Optional[Callable[Dict]] = None,
...
**kwargs,
) -> Dict[str, Any]:
# passing to
def decode_complete(
self,
jwt: str,
...
# hook for custom payload decompression
decompress_payload: Optional[Callable[Dict]] = None,
...
# kwargs
**kwargs,
) -> Dict[str, Any]:
Then checking if the function has been passed and use it or proceed with default
@russoale Possibly, but those are pretty arg-heavy functions as-is. Also, "decompress" is not a good name – the function can do something else than just decompress.
@akx Would it be possible to add a similar hook for the encode
function as well?
@simon-sk Good idea. Added.
This enables custom subclasses of
PyJWT
to customize decoding of thepayload
data of the JWS.There's an example on how to subclass the function in the test case.
Refs #666 (reimplementation of it) Refs #753 (reimplementation of it, borrows test case)