django-defender: 0.9.5 doesn't work without defining password for redis anymore

Hello!

After upgrading to 0.9.5 if no password defined for redis url will throw an error:

redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a bytes, string, int or float first.

redis.exceptions.AuthenticationWrongNumberOfArgsError: wrong number of arguments for 'auth' command On 0.9.4 works fine.

BR, Dacian

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 36

Commits related to this issue

Most upvoted comments

That error happend to me too and also only on the production server. What I did was:

  1. Setting password “mypassword” for redis on the server (by editting /etc/redis/redis.conf or via redis-cli):
root@server:~# redis-cli 
127.0.0.1:6379> config set requirepass mypassword
127.0.0.1:6379> quit
root@server:~# service redis-server restart
  1. Adding DEFENDER_REDIS_URL to Django’s settings.py:
DEFENDER_REDIS_URL = 'redis://:mypassword@localhost:6379/0'

That’s it. To see blocked users/ips:

root@server:~# redis-cli
127.0.0.1:6379> auth mypassword
127.0.0.1:6379> scan 0

To quick check, for example, if the user “admin” is blocked:

127.0.0.1:6379> get defender:blocked:username:admin

To quick unblock user “admin”:

127.0.0.1:6379> del defender:blocked:username:admin