IndominusByte / fastapi-jwt-auth

FastAPI extension that provides JWT Auth support (secure, easy to use, and lightweight)
http://indominusbyte.github.io/fastapi-jwt-auth/
MIT License
627 stars 143 forks source link

An async function for token_in_denylist_loader is no awaited #83

Open Altaroc opened 2 years ago

Altaroc commented 2 years ago

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.