Skip to content

Commit

Permalink
Merge pull request #148 from bestit/feature/OXAP-343-use-random-bytes
Browse files Browse the repository at this point in the history
Feature/oxap 343 use random bytes
  • Loading branch information
mKnoop authored Feb 8, 2021
2 parents 653111e + c7d11de commit 829a8db
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 66 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec2.0.0.html).
## [3.6.7] - 2020-02-05
### Fixed
- Use random_bytes

## [3.6.6] - 2020-02-02
### Fixed
- Adds a secret key to the controller
Expand Down
36 changes: 5 additions & 31 deletions application/controllers/admin/bestitamazonpay4oxid_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @version GIT: $Id$
* @link http://www.bestit-online.de
*/
require_once dirname(__FILE__).'/../../../vendor/paragonie/random_compat/lib/random.php';

This comment has been minimized.

Copy link
@BenjaminJoerger

BenjaminJoerger Feb 9, 2021

Looks like a wrong inclusion path when installing the module by composer:

[09 Feb 00:15:24.354332 2021] [uncaught error] [type E_COMPILE_ERROR] [file /var/www/oxideshop/source/modules/bestit/amazonpay4oxid/application/controllers/admin/bestitamazonpay4oxid_init.php] [line 23] [code ] [message require_once(): Failed opening required '/var/www/oxideshop/source/modules/bestit/amazonpay4oxid/application/controllers/admin/../../../vendor/paragonie/random_compat/lib/random.php' (include_path='/var/www/oxideshop/vendor/symfony/yaml:.:/usr/local/lib/php')]


/**
* Class bestitAmazonPay4Oxid_init
Expand Down Expand Up @@ -354,44 +355,17 @@ public static function onDeactivate()
}

/**
* @see https://gist.github.com/tylerhall/521810
* Generates a strong password of N length containing at least one lower case letter,
* one uppercase letter and one digit. The remaining characters
* in the password are chosen at random from those four sets.
*
* The available characters in each set are user friendly - there are no ambiguous
* characters such as i, l, 1, o, 0, etc. This makes it much easier for users to manually
* type or speak their passwords.
*
* @param int $length
* Generates a strong password using random_bytes
*
* @return string
*/
protected static function _generatePassword($length = 15)
protected static function _generatePassword()
{
$sets = array();
$sets[] = 'abcdefghjkmnpqrstuvwxyz';
$sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ';
$sets[] = '23456789';

$pool = '';
$password = '';

foreach ($sets as $set) {
$password .= $set[array_rand(str_split($set))];
$pool .= $set;
}

$pool = str_split($pool);
for ($i = 0; $i < $length - count($sets); ++$i) {
$password .= $pool[array_rand($pool)];
}
$password = str_shuffle($password);
$bytes = random_bytes(32);

return $password;
return bin2hex($bytes);
}


/**
* Returns the current installed version.
*
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "oxideshop-module",
"keywords": ["oxid", "modules", "eShop"],
"homepage": "https://www.bestit-online.de",
"version": "3.6.6",
"version": "3.6.7",
"license": [
"GPL-3.0-only",
"proprietary"
Expand All @@ -24,7 +24,8 @@
"ext-curl": "*",
"ext-openssl": "*",
"amzn/amazon-pay-sdk-php": "~3.4.1",
"monolog/monolog": "^1.23"
"monolog/monolog": "^1.23",
"paragonie/random_compat": "<9.99"
},
"autoload": {
"exclude-from-classmap": ["/vendor/phpunit/", "/vendor/sebastian/"]
Expand Down
53 changes: 51 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 5 additions & 30 deletions ext/bestitamazonpay4oxid_module_config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
require_once dirname(__FILE__).'/../vendor/paragonie/random_compat/lib/random.php';

/**
* Extension for OXID module_config controller
Expand Down Expand Up @@ -77,40 +78,14 @@ public function saveConfVars()
}

/**
* @see https://gist.github.com/tylerhall/521810
* Generates a strong password of N length containing at least one lower case letter,
* one uppercase letter and one digit. The remaining characters
* in the password are chosen at random from those four sets.
*
* The available characters in each set are user friendly - there are no ambiguous
* characters such as i, l, 1, o, 0, etc. This makes it much easier for users to manually
* type or speak their passwords.
*
* @param int $length
* Generates a strong password using random_bytes
*
* @return string
*/
protected static function _generatePassword($length = 15)
protected static function _generatePassword()
{
$sets = array();
$sets[] = 'abcdefghjkmnpqrstuvwxyz';
$sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ';
$sets[] = '23456789';

$pool = '';
$password = '';

foreach ($sets as $set) {
$password .= $set[array_rand(str_split($set))];
$pool .= $set;
}

$pool = str_split($pool);
for ($i = 0; $i < $length - count($sets); ++$i) {
$password .= $pool[array_rand($pool)];
}
$password = str_shuffle($password);
$bytes = random_bytes(32);

return $password;
return bin2hex($bytes);
}
}
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<b style="color: red">Wenn Sie das Modul von einer vorhergehenden Version updaten muss das Module deaktivert und erneut aktiviert werden</b>'
),
'thumbnail' => 'bestitamazonpay4oxid_logo.png',
'version' => '3.6.6',
'version' => '3.6.7',
'author' => 'best it GmbH & Co. KG',
'url' => 'http://www.bestit-online.de',
'email' => 'support@bestit-online.de',
Expand Down

0 comments on commit 829a8db

Please sign in to comment.