Adding bcrypt() to passwords field
To make your password more secure, you can try a bcrypt() hash with $password = bcrypt($password,12); before inserting into the oauth table.
In Storage/ folder, change the checkClientCredentials() return line to:
return $result['client_secret'] == crypt($client_secret, $result['client_secret'] );
And the checkPassword() return line to:
return $user['password'] == crypt($password, $user['password'] );
Note: It won't help protect bad passwords like `1234', more details from this link: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php - it contains newer code for PHP5.5 also
Addendum: Here is my own flavor of bcrypt.php:
<?php
if(CRYPT_BLOWFISH != 1) {
throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt");
}
function bcrypt($password,$cost)
{
$salt=sprintf('$2y$%02d$',$cost);
//For PHP < PHP 5.3.7 use this instead
// $salt=sprintf('$2a$%02d$',$cost);
$random = uniqid($salt,true);
return crypt($password,$random);
}
Is your goal here to implement this in the default StorageInterface classes?
To verify a password with the hash stored in database, I'd require the hash's salt, hence StorageInterface is the best insertion point for a this quick hack without resorting to lengthy logic within the application code.
We do not want to encrypt client secrets in the default implementation (clients are assigned secrets, and so we need to be able to provide it for them - most OAuth2.0 servers do this). However, if you'd like to extend the ClientStorage class to do this, there is no problem in doing so.
For the UserStorage object, we shouldn't be storing passwords in plaintext per default. This has now been updated to atleast perform a sha hash of the password. However, it is still STRONGLY ENCOURAGED to extend this to be your own user storage implementation