Hello

Memcached daemon supports authentication via SASL.
http://code.google.com/p/memcached/wiki/SASLAuthProtocol

This can be used to effectively limit which users on a system can access memcached, as well as to strengthen it's security (not cool if user A can read data from user B...) -- particularly useful on a shared hosting environment or on a open system.

Unfortunately MS doesn't support this feature yet.

How to enable SASL in Memcached daemon:
http://code.google.com/p/memcached/wiki/SASLHowto
- add the flag "-S" in /etc/memcached.conf (Debian);
- create an user for the login being used for memcached under php: "sudo saslpasswd2 -a memcached -c someuser" and type a password;

Enable SASL in Memcached PECL extension:4
http://php.net/manual/en/book.memcached.php
- add the option "memcached.use_sasl = 1" in /etc/php5/mods-available/memcached.ini or on your site's php.ini;

Note: Memcache PECL extension does not seem to support SASL.

Test with:

<?php
$m = new Memcached();
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->setSaslAuthData("someuser", "password");
?>

SASL auth is controlled via setSaslAuthData.
I figure the complexity required to implement this in MS is not too high.

Comments

spleshka’s picture

Assigned: Unassigned » spleshka

Good catch, thanks! Going to provide a patch soon.

lpalgarvio’s picture

forgot to mention that binary protocol is a requirement.
documentation perhaps could mention that =P

spleshka’s picture

May be we should do this way: if sasl auth is enabled, then binary protocol gets automatically enabled?

spleshka’s picture

I mean in MS configuration, of cource.

lpalgarvio’s picture

that looks good

spleshka’s picture

Okey, great. Then we'll do like this.

spleshka’s picture

Status: Active » Needs review
StatusFileSize
new3.02 KB

Does this patch seems correct for you?

spleshka’s picture

Oh, small typo in word "password".

spleshka’s picture

Status: Needs review » Fixed

I've tested this - works perfectly. Thanks again, commited and pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

lpalgarvio’s picture

Issue summary: View changes

Hello
I haven't been able to find time to test this.

May you also give credit to me for this commit? Thanks