Bug 242011 - mysql ENCRYPT not available on windows - hinders development
Summary: mysql ENCRYPT not available on windows - hinders development
Status: RESOLVED FIXED
Alias: None
Product: Babel
Classification: Technology
Component: Server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Babel server inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-07-24 14:36 EDT by Matthew Mazaika CLA
Modified: 2008-08-11 16:58 EDT (History)
1 user (show)

See Also:


Attachments
patch to allow authentication on both windows and linux (3.26 KB, patch)
2008-07-30 11:30 EDT, Matthew Mazaika CLA
denis.roy: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Mazaika CLA 2008-07-24 14:36:14 EDT
Logging into a babel server running on windows is not possible because mysql uses it's built in "ENCRYPT" function to hash the user's password.

"If crypt() is not available on your system (as is the case with Windows), ENCRYPT() always returns NULL."

http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_encrypt



Gabe O'Brien: To remedy the situation for local testing and developing on Windows we might want to define a constant like WINDOWS_ENVIRONMENT. When WINDOWS_ENVIRONMENT is set to true use a different set of MySQL queries that use the PHP MD5 command or something else like that to obfuscate the password for storing in the database.
Comment 1 Matthew Mazaika CLA 2008-07-30 11:30:28 EDT
Created attachment 108760 [details]
patch to allow authentication on both windows and linux

PHP5 has a built-in "crypt()" function that works EXACTLY the same as the mySQL "ENCRYPT()" function.

I created and tested the following patch on windows and linux and it produces the same hash results as the MySQL function.


Since the hash is an input to the crypt function, and this was previously handled at the database layer, one additional database call must be made at the application layer to replicate the same user authentication: first, one to get their hash and then second to actually execute the authentication against the hash.
Comment 2 Denis Roy CLA 2008-07-30 13:54:44 EDT
I've committed your patch -- thanks.
Comment 3 Denis Roy CLA 2008-08-11 16:07:30 EDT
I've tested this on the staging area.  It's ready for release.

Thanks again for the patch.

Gabe: this is the bug you were looking for.
Comment 4 Gabe O'Brien CLA 2008-08-11 16:58:07 EDT
Sure was Denis.. thanks for committing these changes.