Explicit username/password support #11

Closed
melo opened this Issue Mar 6, 2012 · 6 comments

2 participants

@melo
Home of Redis.pm and related modules member

Moved from RT: https://rt.cpan.org/Ticket/Display.html?id=75562

On Mon Mar 05 19:34:12 2012, ETHER wrote:

It doesn't look like the constructor accepts username/password options,
which is the usual place where a client would specify its credentials.

True, it should.

I see that authentication can be done by sending the AUTH command
(http://redis.io/commands/auth), which should be available via
$redis->auth and the magic of AUTOLOAD, but this is not instantly
obvious to all users of the client, so it would be nice if the
constructor handled this.

Agreed.

I'd be happy to patch in this support, if I could only figure out where
you keep the source... it doesn't seem to be on github, and there is no
relevant meta information in your META.yml.

It is on Github. And thanks for pointing out that the information is not in the documentation. Time to convert that dist to Dist::Zilla to avoid this oversights.

http://github.com/melo/perl-redis/

(I also see some documentation errors, which I'd also be happy to supply
a patch for.)

Feel free to send pull requests, I'm planning on working on Redis the next weekend, to make a release next week. At least the auth information in the constructor would be nice to have.

Bye

@melo melo added a commit that referenced this issue Mar 12, 2012
@melo melo Add support for automatic AUTH command on connect:
If a password attr is given to new, Redis.pm will automatically send the
AUTH command after every connection.

First part of #11, but behaviour with auto-reconnect and tests still not
finished.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
c129a9a
@melo
Home of Redis.pm and related modules member

I didn't include this into the 1.950 release. I still want to think a bit what to do when the password fails and we have auto-reconnect on.

Should we just keep trying? or just really really die?

Also I want to add proper tests, but I want to fix #13 before doing so.

Right now the code is in the auto_auth branch if you want to experiment. Just pass password => 'something' to the new() constructor.

@melo
Home of Redis.pm and related modules member

I responded to an email question about this just now. In my reply I suggested using this as a temporary solution. Please note, I did not test this but "it should work"™ :)

package My::Redis;

use strict;
use base 'Redis';

sub __connect {
  my $self = shift;

  $self->SUPER::__connect(@_);
  $self->auth('your_password');

  return;
}

1;
@arbeca

Hello,
Do you have any idea when you will release this feature (password in new method) ?
Thanks

@melo
Home of Redis.pm and related modules member

End of this week... I hope to have some free time friday to do a new release, I have several small fixes piled up.

@arbeca

Great, many thanks :)

@melo melo added a commit that referenced this issue Jun 9, 2012
@melo melo Add support for automatic AUTH command on connect:
If a password attr is given to new, Redis.pm will automatically send the
AUTH command after every connection.

First part of #11, but behaviour with auto-reconnect and tests still not
finished.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
b60d1a1
@melo melo added a commit that referenced this issue Jun 9, 2012
@melo melo Take care of bad passwords:
If you create your Redis instance with a bad password, it will die with a
stacktrace. We also disable reconnect to prevent loops.

(updates #11)

Signed-off-by: Pedro Melo <melo@simplicidade.org>
defe631
@melo
Home of Redis.pm and related modules member

Fixed with 1.952, on the way to CPAN.

@melo melo closed this Sep 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment