fastapi-jwt-auth icon indicating copy to clipboard operation
fastapi-jwt-auth copied to clipboard

An async function for token_in_denylist_loader is no awaited

Open Altaroc opened this issue 3 years ago • 1 comments

I think that I missed something but I was not able to get the denylist working with aioredis (async lib). Here is my code :

    @AuthJWT.token_in_denylist_loader
    async def check_token_denylist(decrypted_token):
        jti = decrypted_token["jti"]

        entry = await cache.get(jti)
        tokenIsRevoked = not entry or entry != "true"
        logging.debug(f"Token {jti} is revoked: {tokenIsRevoked}")

        return tokenIsRevoked

Am I doing it wrong or is your lib not ment to be used with aioredis or async function ?

NB : Using asyncio inside check_token_denylist is not a good solution because I have async and sync path operation function.

Altaroc avatar Apr 06 '22 15:04 Altaroc