Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add changes and corner cases to allow casbin-redis-watcher to work with flask authz and redis 5 #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

favipcj
Copy link

@favipcj favipcj commented Oct 4, 2024

Feature description

This PR covers corner cases that are needed when using flask-authz, specifically:

  1. Add should_reload and update_callback methods that flask-authz needs https://github.com/pycasbin/flask-authz/blob/master/flask_authz/casbin_enforcer.py#L66-L67
  2. Retry when Redis times out or when Redis is down for some time
  3. Be able to recreate threads after some time(10sec) that were killed for any reason for example when the redis connection dies even after the configured retries. (This is important when running this watcher + flask-authz)
  4. Add some error handling to the subscribe method to show message errors related to redis and close the redis connection before the thread is killed
  5. Be able to receive a logger instance as an argument when creating the watcher

To make this library work with any Python library Redis version including redis 5, a different instance of the Redis class was created for the subscriber and publisher, as that is required for Redis 5 and still works for other old versions as well.

CI/Unit test Running https://github.com/favipcj/redis-watcher/actions/runs/10965417424. Only a minor change was added to the ci workflow to only release builds in the master branch

…ts disconnected or other cause + create separted redis connections to make it work with redis5
@CLAassistant
Copy link

CLAassistant commented Oct 4, 2024

CLA assistant check
All committers have signed the CLA.

@favipcj favipcj changed the title feat: Add corner cases to work with flask authz and pyredis 5 feat: Add changes and corner cases to allow casbin-redis-watcher to work with flask authz and pyredis 5 Oct 4, 2024
@favipcj favipcj changed the title feat: Add changes and corner cases to allow casbin-redis-watcher to work with flask authz and pyredis 5 feat: Add changes and corner cases to allow casbin-redis-watcher to work with flask authz and redis 5 Oct 4, 2024
@favipcj
Copy link
Author

favipcj commented Nov 6, 2024

hey @hsluoyz when you get a chance, could you please take a look at these changes and let me know if changes are required ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants