Skip to content

Commit

Permalink
Change api_key_plain generation
Browse files Browse the repository at this point in the history
Text::uuid is not cryptographically secure.
  • Loading branch information
stripthis authored Jan 6, 2018
1 parent 2b0e76d commit 69d01a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion en/controllers/components/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ generate these API tokens randomly using libraries from CakePHP::
use Cake\Utility\Text;
use Cake\Event\Event;
use Cake\ORM\Table;
use Cake\Utility\Security;

class UsersTable extends Table
{
Expand All @@ -373,7 +374,7 @@ generate these API tokens randomly using libraries from CakePHP::
$hasher = new DefaultPasswordHasher();

// Generate an API 'token'
$entity->api_key_plain = sha1(Text::uuid());
$entity->api_key_plain = Security::hash(Security::randomBytes(32), 'sha256', false);

// Bcrypt the token so BasicAuthenticate can check
// it during login.
Expand Down

0 comments on commit 69d01a0

Please sign in to comment.