benashford / redis-async-rs

A Rust client for Redis, using Tokio
Apache License 2.0
253 stars 30 forks source link

Auth #63

Closed antialize closed 3 years ago

antialize commented 3 years ago

While it is possible to authenticate with redis using the current interface, it is somewhat tricky to get right, as one has to remember to send yet another AUTH command before repeating the failed command when an connection error occurs. It would make some sense for the library to do this.

This adds a PairedConnectionBuilder that accepts a username and password. Whenever the connection is reestablished an AUTH command is send, and the response inspected before other commands are send.

I have not done too much witch documentation and such yet. I first want to hear if this is a feature that you think it makes sense add, and if yes, if this is the right approach to do it, or if there is some other path I should have taken.

antialize commented 3 years ago

I believe this is ready to merge.

benashford commented 3 years ago

I took this opportunity to do some required house-keeping, including some refactoring to push this logic deeper down so it can also be used for PUBSUB connections and other purposes.

I'll release this as part of a new 0.8 release once I've reviewed my own changes.

benashford commented 3 years ago

This has now been published as part of 0.8.0. It's been renamed to redis_async::client::ClientBuilder, and now has two specific builders paired_connect and pubsub_connect depending on which type of connection required, but apart from that will work in the same way.

antialize commented 3 years ago

Thanks.