rscarrera27 / Sanic-JWT-Extended

⚡️An open source Sanic extension that provides "extended" JWT support
https://sanic-jwt-extended.seonghyeon.dev
MIT License
35 stars 8 forks source link

redis blacklist is throwing an error #30

Open garcia-0E opened 4 years ago

garcia-0E commented 4 years ago

Hello guys.

i'm using the blacklist_enable config property as true and blacklist class is RedisBlacklist, running along sanic with default config:

    manager.config.use_blacklist = True
     manager.config.blacklist_class = RedisBlacklist
     manager.config.blacklist_init_kwargs = {
        "connection_info": {
            "address": "redis://:@127.0.0.1:6379",
            "minsize" : 5,
            "maxsize" : 10
        }
    }

However when i'm using token.revoke() method in any endpoint it crashes and throws : tuple or str expected. Is anyone having the same issue or knows how to solve this?

rscarrera27 commented 4 years ago

Could you show me a detailed traceback?

garcia-0E commented 4 years ago

I'm not able to traceback the exception because it crashes even before entering the function. It seems as internal bug when managing blacklist with redis and token.revoke() is identified within a function

no5ix commented 3 years ago

Could you show me a detailed traceback?

with JWT.initialize(app) as manager:
    manager.config.secret_key = "secret"
    manager.config.jwt_header_key = "x-api-key"
    manager.config.use_blacklist = True
    manager.config.blacklist_class = RedisBlacklist
    manager.config.blacklist_init_kwargs = {
        "connection_info": {
            "address": "redis://:@127.0.0.1:6379",
            "minsize": 5,
            "maxsize": 10,
        }
    }

Traceback (most recent call last): File "C:\Program Files\Python38\lib\site-packages\sanic\app.py", line 724, in handle_request response = await response File "C:\Users\b\Documents\github\shop_sanic_mongodb\sanic_jwt_extended\decorators.py", line 165, in wrapper if JWT.config.use_blacklist and await JWT.blacklist.is_blacklisted( File "C:\Users\b\Documents\github\shop_sanic_mongodb\sanic_jwt_extended\blacklist.py", line 48, in is_blacklisted await RedisConnection.initialize(self.connection_info) File "C:\Users\b\Documents\github\shop_sanic_mongodb\sanic_jwt_extended\redis.py", line 22, in initialize await cls._get_redis_connection() File "C:\Users\b\Documents\github\shop_sanic_mongodb\sanic_jwt_extended\redis.py", line 16, in _get_redis_connection cls.redis = await aioredis.create_redis_pool(cls.connection_info) File "C:\Program Files\Python38\lib\site-packages\aioredis\commands__init__.py", line 188, in create_redis_pool pool = await create_pool(address, db=db, File "C:\Program Files\Python38\lib\site-packages\aioredis\pool.py", line 58, in create_pool await pool._fill_free(override_min=False) File "C:\Program Files\Python38\lib\site-packages\aioredis\pool.py", line 383, in _fill_free conn = await self._create_new_connection(self._address) File "C:\Program Files\Python38\lib\site-packages\aioredis\connection.py", line 81, in create_connection assert isinstance(address, (tuple, list, str)), "tuple or str expected" AssertionError: tuple or str expected