Giter Club home page Giter Club logo

Comments (14)

manjuraj avatar manjuraj commented on August 21, 2024

Twemproxy can only support redis commands that takes "key" as an argument. This is the case because sharding layer of twemproxy routes redis commands based on consistent hashed values on "key".

Since AUTH command does not take key as an argument we cannot support this in twemproxy.

Is there a reason why you use AUTH in your setup? Can you make it work without Redis AUTH?

from twemproxy.

therealbill avatar therealbill commented on August 21, 2024

Functionally, yes it would work. However, it is in use for a PHP session backend (slightly modified phpredis) which handles the PHP sessions for thousands of different clients. Thus, if someone were to open a direct connection from within PHP to the Redis nodes they would have access to other clients' session data. Thus, the authentication (compiled into the modified phpredis module) prohibits that.

Thus functionally, yes, but it isn't something that can be allowed for non-technical reasons.

I suppose I could write an auth proxy ....

from twemproxy.

therealbill avatar therealbill commented on August 21, 2024
Or one could treat the auth argument as a key and hash on it. ;)

That would cause a problem if the node it hashed to went down.

from twemproxy.

manjuraj avatar manjuraj commented on August 21, 2024

@therealbill I believe the way redis authentication works is that once a connection to a redis node has been established, the client sends the "AUTH password" command to the redis node before sending any other commands. A failure to do so would mean that the redis server configured with requirepass directive would reject any unautenticated connections.

An auth proxy will not solve the issue, because connections made my twemproxy to backend redis nodes would still be unauthenticated.

The right way to solve this problem IMHO, would be to implemented authentication on the client side so that you have an architecture where clients talking to twemproxy / redis nodes are trusted and hence don't required authentication.

thoughts?

from twemproxy.

therealbill avatar therealbill commented on August 21, 2024

The with proxy idea would essentially handle just the auth and do a direct proxy for all non-auth commands. Less than ideal but potentially workable. It would be ok if the twemcache to redis were unauthenticated in that case because the systems would be isolated from customer reachable nodes.

Ultimately, since the concern is potential unauthorized clients and authorized clients connecting from the same servers there has to be something sitting between the nodes and redis, or redis itself (or the proxy) needs to authenticate with the client.

Another possible route is to locally modify twemproxy to reject any commands other than get, del, and setex - the only commands our custom phpredis sends. That could potentially ameliorate the concerns with unauthorized connections have visibility to the keys and thus the session data from other customers. Though that might still be a significant patch we would have to maintain. At that point I'd have to consider writing a "smaller" version of twemproxy in Python that either handles the authentication from clients and proxies authenticated connections, or simply proxies a subset of commands and does the node key balance and routing operations.

Or the third option of hacking auth into twemproxy myself. Might be an excuse to dust off my C chops.

from twemproxy.

manjuraj avatar manjuraj commented on August 21, 2024

@therealbill I like the first option of "python proxy" only for commands that need auth. I believe this design is clean.

The second option would require hacking of twemproxy. You can easily achieve this by modifying (commenting out) some of the code between https://github.com/twitter/twemproxy/blob/master/src/proto/nc_redis.c#L396 and https://github.com/twitter/twemproxy/blob/master/src/proto/nc_redis.c#L805

Btw, let me know if rackspace is using twemproxy. If so, I will add you guys to the users list (https://github.com/twitter/twemproxy/blob/master/README.md#users)

I will close this issue for now. Let me know once you finish implementing the solution and how you ended up solving your auth issue.

from twemproxy.

ejc3 avatar ejc3 commented on August 21, 2024

Would you accept a pull request that adds auth support into twemproxy? In our deployment, we generally like to restrict the hosts that can connect to a particular system and using auth is a lightweight way of doing that (similar to putting a password on a mysql server).

from twemproxy.

manjuraj avatar manjuraj commented on August 21, 2024

Absolutely! How do you intend to implement AUTH support?

from twemproxy.

charsyam avatar charsyam commented on August 21, 2024

I think. just sending auth command to all connected redis is easy. but Handling irregular cases are hard, for example, one server's setting is different, or and when it failed, I think it can cause many problems which is hard to solve.

from twemproxy.

manjuraj avatar manjuraj commented on August 21, 2024

So, you are saying that when a connection is established to a server, you first send out an AUTH command on that server and only if that succeeds do you use that connection

from twemproxy.

charsyam avatar charsyam commented on August 21, 2024

@manjuraj I have an idea about this. it is using my former patch about reconnection.
It used "set" operation to check. if I change this to use "auth" command. I might think I will work well.
Of course, there is another problem, I should implement extra code for first connection.
reconnection code is only for reconnection. but I think it is not difficult. I will try. and tell you. Thank you.

from twemproxy.

manjuraj avatar manjuraj commented on August 21, 2024

thanks @charsyam! sorry I haven't reviewed your "liveness" code yet. but it is on my plate though

from twemproxy.

ejc3 avatar ejc3 commented on August 21, 2024

@manjraj, thanks for the go-ahead! We'll dig into this and get back to you, assuming charsyam@ doesn't beat us to it. Thanks for the effort on this software.

from twemproxy.

charsyam avatar charsyam commented on August 21, 2024

@manjuraj, @ejc3 Hi, guys, I sent a pull request to support redis auth.
and It doesn't need "liveness code"

#81

from twemproxy.

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.