Skip to content

Commit 7b38d60

Browse files
committed
v1.2.0
1 parent d56abfc commit 7b38d60

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v1.2.0, 2018-07-05
2+
* openssl_random_pseudo_bytes removed
3+
14
# v1.1.0, 2018-04-05
25
* PHP7 support added
36
* Generate a new unique token with openssl_random_pseudo_bytes added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Token Component
2-
![version](https://img.shields.io/badge/version-1.1.0-brightgreen.svg?style=flat-square "Version")
2+
![version](https://img.shields.io/badge/version-1.2.0-brightgreen.svg?style=flat-square "Version")
33
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/flextype-components/token/blob/master/LICENSE)
44

55
The Token component generate and store a unique token which can be used to help prevent [CSRF](http://wikipedia.org/wiki/Cross_Site_Request_Forgery) attacks.

Token.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,7 @@ public static function generate(bool $new = false) : string
4747
if ($new === true OR ! $token) {
4848

4949
// Generate a new unique token
50-
if (function_exists('openssl_random_pseudo_bytes')) {
51-
52-
// Generate a random pseudo bytes token if openssl_random_pseudo_bytes is available
53-
// This is more secure than uniqid, because uniqid relies on microtime, which is predictable
54-
$token = base64_encode(openssl_random_pseudo_bytes(32));
55-
56-
} else {
57-
58-
// Otherwise, fall back to a hashed uniqid
59-
$token = sha1(uniqid(null, true));
60-
}
50+
$token = sha1(uniqid(mt_rand(), true));
6151

6252
// Store the new token
6353
Session::set(Token::$token_name, $token);

0 commit comments

Comments
 (0)