File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ before_script:
31
31
32
32
script :
33
33
- mkdir -p build/logs
34
+ - if [ $(phpenv version-name) = 'hhvm' ]; then echo 'xdebug.enable=1' >> /etc/hhvm/php.ini; fi
34
35
- phpunit --stderr --coverage-clover build/logs/clover.xml
35
36
36
37
after_script :
@@ -42,4 +43,4 @@ after_success:
42
43
cache :
43
44
directories :
44
45
- vendor
45
- - $HOME/.cache/composer
46
+ - $HOME/.cache/composer
Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ public static function refreshToken()
354
354
public static function generateAuthToken ()
355
355
{
356
356
// todo - make this a member method / configurable
357
- $ randLength = 32 ;
357
+ $ randLength = 64 ;
358
358
359
359
//if config tokenLength value is 0 or some non int
360
360
if (intval (self ::$ config ['tokenLength ' ]) == 0 ) {
@@ -363,10 +363,10 @@ public static function generateAuthToken()
363
363
364
364
//#todo - if $length > 128 throw exception
365
365
366
- if (function_exists ("hash_algos " )
367
- && function_exists ( " openssl_random_pseudo_bytes " )
368
- && in_array ( " sha512 " , hash_algos () )) {
369
- $ token = hash ( " sha512 " , openssl_random_pseudo_bytes ($ randLength ));
366
+ if (function_exists ("random_bytes " )) {
367
+ $ token = bin2hex ( random_bytes ( $ randLength ));
368
+ } elseif ( function_exists ( " openssl_random_pseudo_bytes " )) {
369
+ $ token = bin2hex ( openssl_random_pseudo_bytes ($ randLength ));
370
370
} else {
371
371
$ token = '' ;
372
372
for ($ i = 0 ; $ i < 128 ; ++$ i ) {
Original file line number Diff line number Diff line change @@ -356,10 +356,12 @@ public function testGenerateAuthToken()
356
356
357
357
$ this ->assertFalse ($ token1 == $ token2 );
358
358
$ this ->assertEquals (strlen ($ token1 ), 20 );
359
+ $ this ->assertRegExp ('/^[a-z0-9]{20}$/ ' , $ token1 );
359
360
360
361
csrfprotector::$ config ['tokenLength ' ] = 128 ;
361
362
$ token = csrfprotector::generateAuthToken ();
362
363
$ this ->assertEquals (strlen ($ token ), 128 );
364
+ $ this ->assertRegExp ('/^[a-z0-9]{128}$/ ' , $ token );
363
365
}
364
366
365
367
/**
You can’t perform that action at this time.
0 commit comments