GithubHelp home page GithubHelp logo

Support for rediss TLS about cashews HOT 8 CLOSED

krukov avatar krukov commented on May 23, 2024
Support for rediss TLS

from cashews.

Comments (8)

0xAlcibiades avatar 0xAlcibiades commented on May 23, 2024

This would be useful for use over the internet.

from cashews.

Krukov avatar Krukov commented on May 23, 2024

Oh yes, of course we should support redis with tls

If aioredis-py support rediss:// notation in uri it will be simple to add support for it.
Would you like to contribute?

from cashews.

0xAlcibiades avatar 0xAlcibiades commented on May 23, 2024

Yeah, so I did just try adding a match in the client, but it's a bit more complex than that because you have to allow for stuff like this: rq/rq#1468 I'd be glad to contribute the simple change around matching the backend, but not sure how/if you'd like to expose those extra parameters.

from cashews.

Krukov avatar Krukov commented on May 23, 2024

I hope that it is not so complicated as you think, but I could be wrong 😅
We already can pass any parameters to the redis Connection class by setup method:

from cashews import cache 
from aioredis.connection import SSLConnection

cache.setup("redis://?ssl_keyfile=/tmp/test.key", connection_class=SSLConnection)
cache._backends[""][0]._client.connection_pool.connection_kwargs 
# that is kwargs that will passed to a redis connection class  https://github.com/aio-libs/aioredis-py/blob/56d6b325ee246a3eb0fc8bb6803247c86bb2f494/aioredis/connection.py
>>> {'ssl_keyfile': '/tmp/test.ssl', 'client_name': 'cashews', 'health_check_interval': 10, 'socket_keepalive': True, 'retry_on_timeout': False, 'socket_timeout': 0.1, 'decode_responses': False}

So maybe you can use redis over tls with code above, but I think that we should support rediss:// uri schema like aioredis do.

I hope that adding mapping to the settings_url_parse function will be enough, and using redis over tls will be look like:

from caches import cache

cache.setup("rediss://redis_host/1", ssl_cert_reqs=None)
# or
cache.setup("rediss://redis?ssl_ca_certs=/path/to/custom/ca-cert")

from cashews.

0xAlcibiades avatar 0xAlcibiades commented on May 23, 2024

Ok @Krukov please see and review my very small feature, then.

from cashews.

Krukov avatar Krukov commented on May 23, 2024

Thanks @alcibiadeseth!
By the way, did you test it ? I am going to add it to the documentation, I want to be sure that its work )

from cashews.

0xAlcibiades avatar 0xAlcibiades commented on May 23, 2024

I tested it in the sense that it picks up the prefix, but not your bit about how to pass the additional parameters.

from cashews.

Krukov avatar Krukov commented on May 23, 2024

Thanks you !
I have added documentation about rediss and released new version

from cashews.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.