Hello,
I have a system in place with a large mysql based usertable that we want to use to authenticate a mediawiki installation. I want to use the ExtAuthDB extension. Unfortunately the original system was setup using mysql password encryption. (password=password('password')) Since there is no way (that i have found) to decrypt a mysql password in php or encrypt a password in php using mysql encryption I have been having some struggles getting this to work. (as is we are comparing a cleartext password to an encrypted password in the code). If anyone has come up against this or has any suggestions I would love to hear them. I have included the standard ExtAuthDB code below for convenience.
Thanks for your time.
Darren Kemp wrote:
Unfortunately the original system was setup using mysql password encryption. (password=password('password')) Since there is no way (that i have found) to decrypt a mysql password in php or encrypt a password in php using mysql encryption I have been having some struggles getting this to work. (as is we are comparing a cleartext password to an encrypted password in the code).
I don't know MySQL Select statements in gory detail, but doesn't it support something like
SELECT password('cleartextPsw') as encUserPsw
Then just compare the encrypted versions for a match.
Mike
I have solved this issue. Thanks to those who read and offered advice.
Thanks again,
Darren
On Wed, Aug 26, 2009 at 1:39 PM, Michael Dalymichael.daly@kayakwiki.org wrote:
Darren Kemp wrote:
Unfortunately the original system was setup using mysql password encryption. (password=password('password')) Since there is no way (that i have found) to decrypt a mysql password in php or encrypt a password in php using mysql encryption I have been having some struggles getting this to work. (as is we are comparing a cleartext password to an encrypted password in the code).
I don't know MySQL Select statements in gory detail, but doesn't it support something like
SELECT password('cleartextPsw') as encUserPsw
Then just compare the encrypted versions for a match.
Mike
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
"Darren Kemp" darrenkemp@gmail.com wrote in message news:1d83a8940908261052h7feedb1fi5d841db6f99a39a7@mail.gmail.com...
I have solved this issue. Thanks to those who read and offered advice.
Using the method Michael Daly suggested? I know for a fact that I'm going to have to do this on a new project of mine in the next few weeks, it would be nice to have an idea of how to proceed.
--HM
Happy-melon wrote:
"Darren Kemp" darrenkemp@gmail.com wrote in message news:1d83a8940908261052h7feedb1fi5d841db6f99a39a7@mail.gmail.com...
I have solved this issue. Thanks to those who read and offered advice.
Using the method Michael Daly suggested? I know for a fact that I'm going to have to do this on a new project of mine in the next few weeks, it would be nice to have an idea of how to proceed.
--HM
I wouldn't perform an extra query just to encode the password.
MysqlAuthPlugin::authenticate($username, $password) { /**connect to mysql table */ mysql_query("SELECT host FROM user WHERE user='$username' AND password=PASSWORD('$password')"); //Need to be mysql_escaped for any real use
/* Iterate checking that at least one host matches the user one Or simply check that some row was returned, in which case you can add a LIMIT 1. */ }
Basically I just did a query to see if the user exists with the encrypted password.
$res = $db->query("SELECT password FROM users where username='$username' and password=password('$password') "); $row = $db->fetchObject( $res ); $newPass = $row->{'password'};
if we get something back we authed, otherwise we didnt.
Good luck!
Thanks
Darren
On Thu, Aug 27, 2009 at 7:46 AM, PlatonidesPlatonides@gmail.com wrote:
Happy-melon wrote:
"Darren Kemp" darrenkemp@gmail.com wrote in message news:1d83a8940908261052h7feedb1fi5d841db6f99a39a7@mail.gmail.com...
I have solved this issue. Thanks to those who read and offered advice.
Using the method Michael Daly suggested? I know for a fact that I'm going to have to do this on a new project of mine in the next few weeks, it would be nice to have an idea of how to proceed.
--HM
I wouldn't perform an extra query just to encode the password.
MysqlAuthPlugin::authenticate($username, $password) { /**connect to mysql table */ mysql_query("SELECT host FROM user WHERE user='$username' AND password=PASSWORD('$password')"); //Need to be mysql_escaped for any real use
/* Iterate checking that at least one host matches the user one Or simply check that some row was returned, in which case you can add a LIMIT 1. */ }
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Darren Kemp wrote:
Basically I just did a query to see if the user exists with the encrypted password.
$res = $db->query("SELECT password FROM users where
username='$username' and password=password('$password') "); $row = $db->fetchObject( $res ); $newPass = $row->{'password'};
if we get something back we authed, otherwise we didnt.
Good luck!
Thanks
Darren
Yes, that's exactly what I proposed. But don't implement it like that! It's vulnerable to SQL injection. You need to escape $username and $password before including it into the query.
For example, providing as password (for any user) the string ') OR (''=' would *always* be accepted.
Hi! svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3 never worked for me, asks for the password.
I've regenerated my ssh key pair (there probably was something wrong with my old key pair).
May I have ask to reupload my public key to the svn server? http://ingress.uniyar.ac.ru/~sdv/id_rsa.pub
Or, it's better to make a new commit request? I want to upload my extension so it won't get lost and maybe get translated.
http://www.mediawiki.org/wiki/Commit_access_requests/Archive_1#QuestPC
Dmitriy
On Fri, Aug 28, 2009 at 10:11 AM, Dmitriy Sintsovquestpc@rambler.ru wrote:
Hi! svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3 never worked for me, asks for the password.
A checkout on that url should work anonymously. Anyway, a read-write checkout should be done from svn+ssh://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
Bryan
* Bryan Tong Minh bryan.tongminh@gmail.com [Fri, 28 Aug 2009 10:33:54 +0200]:
A checkout on that url should work anonymously. Anyway, a read-write
Sorry, I've copypasted the wrong url.
checkout should be done from svn+ssh://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
Of course, this one doesn't work:
svn checkout svn+ssh://questpc@svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/extensions wiki/extensions questpc@svn.wikimedia.org's password: Permission denied, please try again. questpc@svn.wikimedia.org's password:
Dmitriy
Hello,
you must use your private key and not a "password".
For Linux: Run ssh-add /path/to/your/private/key/file For Windows: Read http://wiki.apisnetworks.com/index.php/Subversion#Windows_Setup
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: wikitech-l-bounces@lists.wikimedia.org [mailto:wikitech-l-bounces@lists.wikimedia.org] Im Auftrag von Dmitriy Sintsov Gesendet: Freitag, 28. August 2009 10:51 An: Wikimedia developers Betreff: Re: [Wikitech-l] SVN commit access
* Bryan Tong Minh bryan.tongminh@gmail.com [Fri, 28 Aug 2009 10:33:54 +0200]:
A checkout on that url should work anonymously. Anyway, a read-write
Sorry, I've copypasted the wrong url.
checkout should be done from svn+ssh://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
Of course, this one doesn't work:
svn checkout svn+ssh://questpc@svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/extension s wiki/extensions questpc@svn.wikimedia.org's password: Permission denied, please try again. questpc@svn.wikimedia.org's password:
Dmitriy
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
* Jan Luca jan@jans-seite.de [Sun, 30 Aug 2009 14:35:00 +0200]:
Hello,
you must use your private key and not a "password".
Hello, Jan! I've been asking about this problem in IRC. I've been suggested debug using ssh-l questpc -vvv svn.wikimedia.org . It the debug log (-vvv) it says the order is publickey, then password. It tires the password only because publickey fails. Switched to old key pair, but no luck. I'll try to figure out by myself. Until that, I am just re-submitting the request with new public key.
For Linux: Run ssh-add /path/to/your/private/key/file
I use linux in this case. My mistake probably was that the first (old) keys were generated by "trial-and-error" studying ssh options, only at the second attempt I've processed according to FAQ:
http://sial.org/howto/openssh/publickey-auth/
BTW, they say that authorization should work without setting up nohup ssh-agent -s > ~/.ssh-agent and using ssh-add.
ssh-agent and ssh-add are only the handy way to cache your passphrase: "To reduce the frequency with which the key passphrase must be typed in, setup a ssh-agent(1) daemon to hold the private portion of the RSA key pair for the duration of a session. There are several ways to run and manage ssh-agent, for example from a X11 login script or with a utility like Keychain. These notes rely on the setup of ssh-agent via an @reboot crontab(5) entry, along with appropriate shell configuration." Dmitriy
wikitech-l@lists.wikimedia.org