Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
26
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/CHANGELOG.md
vendored
Normal file
26
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
## Change Log
|
||||
|
||||
## [2.0.1] - 2020-10-17
|
||||
### Removed
|
||||
- Support for Bacon QRCode 1.x
|
||||
|
||||
## [2.0.0] - 2020-10-16
|
||||
### Changed
|
||||
- Add support for SVG QRCodes
|
||||
- No need to install the Imagick extension
|
||||
- Allow users to define their on QRCode service renderer
|
||||
- Breaking change: beginning on version 2.0 the rendering service is optional, so you have to manually install one of those packages in order to generate QRCodes: [BaconQrCode](https://github.com/Bacon/BaconQrCode): renders PNG by default, but requires the Imagick PHP extension. [chillerlan/php-qrcode](https://github.com/chillerlan/php-qrcode): renders SVG by default and don't require the Imagick PHP extension.
|
||||
- Add PHP 8.0 compatibility
|
||||
|
||||
## [1.0.2] - 2018-10-10
|
||||
### Changed
|
||||
- Dropped support for PHP 5.4 & PHP 5.5
|
||||
- Test QRCode by decoding it
|
||||
|
||||
## [1.0.1] - 2018-10-10
|
||||
### Added
|
||||
- Add support for more image renderer back ends
|
||||
|
||||
## [1.0.0] - 2018-10-06
|
||||
### Added
|
||||
- Package created
|
7
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/LICENSE.md
vendored
Normal file
7
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright 2014-2018 Phil, Antonio Carlos Ribeiro and All Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
149
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/README.md
vendored
Normal file
149
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/README.md
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
# Google2FA QRCode
|
||||
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/pragmarx/google2fa-qrcode"><img alt="Latest Stable Version" src="https://img.shields.io/packagist/v/pragmarx/google2fa-qrcode.svg?style=flat-square"></a>
|
||||
<a href="LICENSE.md"><img alt="License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
|
||||
<a href="https://scrutinizer-ci.com/g/antonioribeiro/google2fa/?branch=master"><img alt="Code Quality" src="https://img.shields.io/scrutinizer/g/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
<a href="https://travis-ci.org/antonioribeiro/google2fa"><img alt="Build" src="https://img.shields.io/travis/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/pragmarx/google2fa-qrcode"><img alt="Downloads" src="https://img.shields.io/packagist/dt/pragmarx/google2fa-qrcode.svg?style=flat-square"></a>
|
||||
<a href="https://scrutinizer-ci.com/g/antonioribeiro/google2fa/?branch=master"><img alt="Coverage" src="https://img.shields.io/scrutinizer/coverage/g/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
<a href="https://styleci.io/repos/24296182"><img alt="StyleCI" src="https://styleci.io/repos/24296182/shield"></a>
|
||||
<a href="https://travis-ci.org/antonioribeiro/google2fa"><img alt="PHP" src="https://img.shields.io/badge/PHP-5.4%20--%207.3-brightgreen.svg?style=flat-square"></a>
|
||||
</p>
|
||||
|
||||
### QRCode For Google2FA
|
||||
|
||||
This is package is [Goole2FA](https://github.com/antonioribeiro/google2fa) integrated with a QRCode generator, providing an easy way to plot QRCode for your two factor authentication. For documentation related to Google2FA, please check the [documentation of the main package](https://github.com/antonioribeiro/google2fa).
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 5.4+
|
||||
|
||||
## Installing
|
||||
|
||||
Use Composer to install it:
|
||||
|
||||
```
|
||||
composer require pragmarx/google2fa-qrcode
|
||||
```
|
||||
|
||||
## Using It
|
||||
|
||||
### Instantiate it directly
|
||||
|
||||
```php
|
||||
use PragmaRX\Google2FAQRCode\Google2FA;
|
||||
|
||||
$google2fa = new Google2FA();
|
||||
|
||||
return $google2fa->generateSecretKey();
|
||||
```
|
||||
|
||||
## Generating QRCodes
|
||||
|
||||
The securer way of creating QRCode is to do it yourself or using a library. First you have to install the BaconQrCode package, as stated above, then you just have to generate the inline string using:
|
||||
|
||||
```php
|
||||
$inlineUrl = $google2fa->getQRCodeInline(
|
||||
$companyName,
|
||||
$companyEmail,
|
||||
$secretKey
|
||||
);
|
||||
```
|
||||
|
||||
And use it in your blade template this way:
|
||||
|
||||
```html
|
||||
<img src="{{ $inlineUrl }}">
|
||||
```
|
||||
|
||||
```php
|
||||
$secretKey = $google2fa->generateSecretKey(16, $userId);
|
||||
```
|
||||
|
||||
## Show the QR Code to your user, via Google Apis
|
||||
|
||||
It's insecure to use it via Google Apis, so you have to enable it before using it.
|
||||
|
||||
```php
|
||||
$google2fa->setAllowInsecureCallToGoogleApis(true);
|
||||
|
||||
$google2fa_url = $google2fa->getQRCodeGoogleUrl(
|
||||
'YourCompany',
|
||||
$user->email,
|
||||
$user->google2fa_secret
|
||||
);
|
||||
|
||||
/// and in your view:
|
||||
|
||||
<img src="{{ $google2fa_url }}" alt="">
|
||||
```
|
||||
|
||||
And they should see and scan the QR code to their applications:
|
||||
|
||||

|
||||
|
||||
And to verify, you just have to:
|
||||
|
||||
```php
|
||||
$secret = $request->input('secret');
|
||||
|
||||
$valid = $google2fa->verifyKey($user->google2fa_secret, $secret);
|
||||
```
|
||||
|
||||
## Replacing the QRCode rendering service
|
||||
|
||||
If you want to use a different service, you just have to
|
||||
|
||||
```php
|
||||
$google2fa->setQrcodeService(new YourService())
|
||||
->getQRCodeInline(
|
||||
$companyName,
|
||||
$companyEmail,
|
||||
$secretKey
|
||||
);
|
||||
```
|
||||
|
||||
## Built-in QRCode rendering services
|
||||
|
||||
Beginning on version 2.0 the rendering service is optional, so you have to manually install one of those packages in order to generate QRCodes:
|
||||
|
||||
- [BaconQrCode](https://github.com/Bacon/BaconQrCode): renders PNG by default, but requires the Imagick PHP extension. You can configure it to use different backends, but you'll have to instantiate it yourself.
|
||||
- [chillerlan/php-qrcode](https://github.com/chillerlan/php-qrcode): renders SVG by default and don't require the Imagick PHP extension, but can also generate other formats, which may require Imagick.
|
||||
|
||||
## Using a diffent image backend
|
||||
|
||||
```php
|
||||
$google2fa->setQrcodeService(
|
||||
new \PragmaRX\Google2FAQRCode\QRCode\Bacon(
|
||||
new \BaconQrCode\Renderer\Image\SvgImageBackEnd()
|
||||
)
|
||||
);
|
||||
|
||||
// or
|
||||
|
||||
$google2fa = new Google2FA(
|
||||
new Bacon(
|
||||
new \BaconQrCode\Renderer\Image\SvgImageBackEnd()
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
The package tests were written with [PHPUnit](https://phpunit.de/).
|
||||
|
||||
## Authors
|
||||
|
||||
- [Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)
|
||||
- [All Contributors](https://github.com/antonioribeiro/google2fa/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
Google2FAQRCode is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and issues are more than welcome.
|
41
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/composer.json
vendored
Normal file
41
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/composer.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "pragmarx/google2fa-qrcode",
|
||||
"description": "QR Code package for Google2FA",
|
||||
"keywords": ["authentication", "two factor authentication", "google2fa", "2fa", "QRCode", "qr code"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Antonio Carlos Ribeiro",
|
||||
"email": "acr@antoniocarlosribeiro.com",
|
||||
"role": "Creator & Designer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"pragmarx/google2fa": ">=4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4|~5|~6|~7|~8|~9",
|
||||
"khanamiryan/qrcode-detector-decoder": "^1.0",
|
||||
"bacon/bacon-qr-code": "^2.0",
|
||||
"chillerlan/php-qrcode": "^1.0|^2.0|^3.0|^4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PragmaRX\\Google2FAQRCode\\": "src/",
|
||||
"PragmaRX\\Google2FAQRCode\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"bacon/bacon-qr-code": "For QR Code generation, requires imagick",
|
||||
"chillerlan/php-qrcode": "For QR Code generation"
|
||||
},
|
||||
"extra": {
|
||||
"component": "package",
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FAQRCode\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class MissingQrCodeServiceException extends Exception
|
||||
{
|
||||
}
|
112
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/Google2FA.php
vendored
Normal file
112
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/Google2FA.php
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FAQRCode;
|
||||
|
||||
use BaconQrCode\Writer;
|
||||
use BaconQrCode\Renderer\Image\Png;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use PragmaRX\Google2FAQRCode\QRCode\Bacon;
|
||||
use PragmaRX\Google2FAQRCode\QRCode\Chillerlan;
|
||||
use BaconQrCode\Renderer\Image\RendererInterface;
|
||||
use BaconQrCode\Writer as BaconQrCodeWriter;
|
||||
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||
use PragmaRX\Google2FA\Google2FA as Google2FAPackage;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Renderer\Image\ImageBackEndInterface;
|
||||
use PragmaRX\Google2FAQRCode\Exceptions\MissingQrCodeServiceException;
|
||||
|
||||
class Google2FA extends Google2FAPackage
|
||||
{
|
||||
/**
|
||||
* @var ImageBackEndInterface|RendererInterface|null $imageBackEnd
|
||||
*/
|
||||
protected $qrCodeService;
|
||||
|
||||
/**
|
||||
* Google2FA constructor.
|
||||
*
|
||||
* @param ImageBackEndInterface|RendererInterface|null $imageBackEnd
|
||||
*/
|
||||
public function __construct($qrCodeService = null)
|
||||
{
|
||||
$this->setQrCodeService(
|
||||
empty($qrCodeService)
|
||||
? $this->qrCodeServiceFactory()
|
||||
: $qrCodeService
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a QR code data url to display inline.
|
||||
*
|
||||
* @param string $company
|
||||
* @param string $holder
|
||||
* @param string $secret
|
||||
* @param int $size
|
||||
* @param string $encoding Default to UTF-8
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQRCodeInline(
|
||||
$company,
|
||||
$holder,
|
||||
$secret,
|
||||
$size = 200,
|
||||
$encoding = 'utf-8'
|
||||
) {
|
||||
if (empty($this->getQrCodeService())) {
|
||||
throw new MissingQrCodeServiceException(
|
||||
'You need to install a service package or assign yourself the service to be used.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->qrCodeService->getQRCodeInline(
|
||||
$this->getQRCodeUrl($company, $holder, $secret),
|
||||
$size,
|
||||
$encoding
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Service setter
|
||||
*
|
||||
* @return \PragmaRX\Google2FAQRCode\QRCode\QRCodeServiceContract
|
||||
*/
|
||||
public function getQrCodeService()
|
||||
{
|
||||
return $this->qrCodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Service setter
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setQrCodeService($service)
|
||||
{
|
||||
$this->qrCodeService = $service;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the QR Code service instance
|
||||
*
|
||||
* @return \PragmaRX\Google2FAQRCode\QRCode\QRCodeServiceContract
|
||||
*/
|
||||
public function qrCodeServiceFactory()
|
||||
{
|
||||
if (
|
||||
class_exists('BaconQrCode\Writer') &&
|
||||
class_exists('BaconQrCode\Renderer\ImageRenderer')
|
||||
) {
|
||||
return new Bacon();
|
||||
}
|
||||
|
||||
if (class_exists('chillerlan\QRCode\QRCode')) {
|
||||
return new Chillerlan();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
97
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/Bacon.php
vendored
Normal file
97
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/Bacon.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FAQRCode\QRCode;
|
||||
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Writer as BaconQrCodeWriter;
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\Image\ImageBackEndInterface;
|
||||
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
|
||||
class Bacon implements QRCodeServiceContract
|
||||
{
|
||||
/**
|
||||
* @var ImageBackEndInterface|RendererInterface|null $imageBackEnd
|
||||
*/
|
||||
protected $imageBackEnd;
|
||||
|
||||
/**
|
||||
* Google2FA constructor.
|
||||
*
|
||||
* @param ImageBackEndInterface|RendererInterface|null $imageBackEnd
|
||||
*/
|
||||
public function __construct($imageBackEnd = null)
|
||||
{
|
||||
$this->imageBackEnd = $imageBackEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a QR code data url to display inline.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $size
|
||||
* @param string $encoding Default to UTF-8
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQRCodeInline($string, $size = 200, $encoding = 'utf-8')
|
||||
{
|
||||
$renderer = new ImageRenderer(
|
||||
(new RendererStyle($size))->withSize($size),
|
||||
$this->getImageBackEnd()
|
||||
);
|
||||
|
||||
$bacon = new Writer($renderer);
|
||||
|
||||
$data = $bacon->writeString($string, $encoding);
|
||||
|
||||
if ($this->getImageBackEnd() instanceof ImagickImageBackEnd) {
|
||||
return 'data:image/png;base64,' . base64_encode($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Imagick is available
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function imagickIsAvailable()
|
||||
{
|
||||
return extension_loaded('imagick');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image backend
|
||||
*
|
||||
* @return ImageRenderer
|
||||
*/
|
||||
public function getImageBackend()
|
||||
{
|
||||
if (empty($this->imageBackEnd)) {
|
||||
$this->imageBackEnd = !$this->imagickIsAvailable()
|
||||
? new SvgImageBackEnd()
|
||||
: new ImagickImageBackEnd();
|
||||
}
|
||||
|
||||
$this->setImageBackEnd($this->imageBackEnd);
|
||||
|
||||
return $this->imageBackEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image backend
|
||||
*
|
||||
* @param $imageBackEnd
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageBackend($imageBackEnd)
|
||||
{
|
||||
$this->imageBackEnd = $imageBackEnd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
80
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/Chillerlan.php
vendored
Normal file
80
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/Chillerlan.php
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FAQRCode\QRCode;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use BaconQrCode\Writer as BaconQrCodeWriter;
|
||||
|
||||
class Chillerlan implements QRCodeServiceContract
|
||||
{
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Get QRCode options.
|
||||
*
|
||||
* @param int $size
|
||||
* @return \chillerlan\QRCode\QROptions
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = new QROptions($this->buildOptionsArray());
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set QRCode options.
|
||||
*
|
||||
* @param array $options
|
||||
* @return self
|
||||
*/
|
||||
protected function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the options array
|
||||
*
|
||||
* @param null $size
|
||||
* @return array
|
||||
*/
|
||||
public function buildOptionsArray($size = null)
|
||||
{
|
||||
$defaults = [
|
||||
'version' => QRCode::VERSION_AUTO,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
];
|
||||
|
||||
return array_merge($defaults, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a QR code data url to display inline.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $size
|
||||
* @param string $encoding Default to UTF-8
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQRCodeInline($string, $size = null, $encoding = null)
|
||||
{
|
||||
$renderer = new QRCode($this->getOptions());
|
||||
|
||||
$header = "data:image/svg+xml;base64,";
|
||||
|
||||
$image = $renderer->render($string);
|
||||
|
||||
if (strncmp($image, $header, strlen($header)) === 0) {
|
||||
return $image;
|
||||
}
|
||||
|
||||
return $header . base64_encode($image);
|
||||
}
|
||||
}
|
17
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/QRCodeServiceContract.php
vendored
Normal file
17
admin/phpMyAdmin/vendor/pragmarx/google2fa-qrcode/src/QRCode/QRCodeServiceContract.php
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FAQRCode\QRCode;
|
||||
|
||||
interface QRCodeServiceContract
|
||||
{
|
||||
/**
|
||||
* Generates a QR code data url to display inline.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $size
|
||||
* @param string $encoding Default to UTF-8
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQRCodeInline($string, $size = 200, $encoding = 'utf-8');
|
||||
}
|
111
admin/phpMyAdmin/vendor/pragmarx/google2fa/CHANGELOG.md
vendored
Normal file
111
admin/phpMyAdmin/vendor/pragmarx/google2fa/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
## Change Log
|
||||
|
||||
## [8.0.0] - 2020-05-05
|
||||
### Added
|
||||
- PHP 8 Support
|
||||
- Tests
|
||||
- Extract som test helpers
|
||||
- PHPStan checks
|
||||
### Changed
|
||||
- PHP required version bumped to >= 7.1
|
||||
- Exception interfaces extending Throwable
|
||||
|
||||
## [7.0.0] - 2019-09-21
|
||||
### Added
|
||||
- PHPStan checks
|
||||
### Removed
|
||||
- Constants::ARGUMENT_NOT_SET - This is a BC break
|
||||
|
||||
## [6.1.3] - 2019-09-21
|
||||
### Drafted
|
||||
- To fix inserted BC break
|
||||
|
||||
## [6.1.2] - 2019-09-21
|
||||
### DELETED
|
||||
- To fix inserted BC break
|
||||
|
||||
## [6.1.1] - 2019-09-21
|
||||
### DELETED
|
||||
- To fix inserted BC break
|
||||
|
||||
## [6.0.0] - 2019-09-11
|
||||
### Added
|
||||
- Base exception class and interfaces
|
||||
### Removed
|
||||
- Support for PHP 5.4 to 7.0, will keep supporting PHP 7.1, 7.2, 7.3 & 7.4
|
||||
|
||||
## [5.0.0] - 2019-05-19
|
||||
### Changed
|
||||
- Remove dead Google Charts API
|
||||
|
||||
## [4.0.0] - 2018-10-06
|
||||
### Changed
|
||||
- Bacon QRCode package removed
|
||||
|
||||
## [3.0.1] - 2018-03-15
|
||||
### Changed
|
||||
- Relicensed to MIT
|
||||
|
||||
## [3.0.0] - 2018-03-07
|
||||
### Changed
|
||||
- It's now mandatory to enable Google Api secret key access by executing `setAllowInsecureCallToGoogleApis(true);`
|
||||
|
||||
## [2.0.4] - 2017-06-22
|
||||
### Fixed
|
||||
- Fix Base32 to keep supporting PHP 5.4 && 5.5.
|
||||
|
||||
## [2.0.3] - 2017-06-22
|
||||
## [2.0.2] - 2017-06-21
|
||||
## [2.0.1] - 2017-06-20
|
||||
### Fixed
|
||||
- Minor bugs
|
||||
|
||||
## [2.0.0] - 2017-06-20
|
||||
### Changed
|
||||
- Drop the Laravel support in favor of a bridge package (https://github.com/antonioribeiro/google2fa-laravel).
|
||||
- Using a more secure Base 32 algorithm, to prevent cache-timing attacks.
|
||||
- Added verifyKeyNewer() method to prevent reuse of keys.
|
||||
- Refactored to remove complexity, by extracting support methods.
|
||||
- Created a package playground page (https://pragmarx.com/google2fa)
|
||||
|
||||
## [2.0.0] - 2017-06-20
|
||||
### Changed
|
||||
- Drop the Laravel support in favor of a bridge package (https://github.com/antonioribeiro/google2fa-laravel).
|
||||
- Using a more secure Base 32 algorithm, to prevent cache-timing attacks.
|
||||
- Added verifyKeyNewer() method to prevent reuse of keys.
|
||||
- Refactored to remove complexity, by extracting support methods.
|
||||
- Created a package playground page (https://pragmarx.com/google2fa)
|
||||
|
||||
## [1.0.1] - 2016-07-18
|
||||
### Changed
|
||||
- Drop support for PHP 5.3.7, require PHP 5.4+.
|
||||
- Coding style is now PSR-2 automatically enforced by StyleCI.
|
||||
|
||||
## [1.0.0] - 2016-07-17
|
||||
### Changed
|
||||
- Package bacon/bacon-qr-code was moved to "suggest".
|
||||
|
||||
## [0.8.1] - 2016-07-17
|
||||
### Fixed
|
||||
- Allow paragonie/random_compat ~1.4|~2.0.
|
||||
|
||||
## [0.8.0] - 2016-07-17
|
||||
### Changed
|
||||
- Bumped christian-riesen/base32 to ~1.3
|
||||
- Use paragonie/random_compat to generate cryptographically secure random secret keys
|
||||
- Readme improvements
|
||||
- Drop simple-qrcode in favor of bacon/bacon-qr-code
|
||||
- Fix tavis setup for phpspec, PHP 7, hhvm and improve cache
|
||||
|
||||
## [0.7.0] - 2015-11-07
|
||||
### Changed
|
||||
- Fixed URL generation for QRCodes
|
||||
- Avoid time attacks
|
||||
|
||||
## [0.2.0] - 2015-02-19
|
||||
### Changed
|
||||
- Laravel 5 compatibility.
|
||||
|
||||
## [0.1.0] - 2014-07-06
|
||||
### Added
|
||||
- First version.
|
7
admin/phpMyAdmin/vendor/pragmarx/google2fa/LICENSE.md
vendored
Normal file
7
admin/phpMyAdmin/vendor/pragmarx/google2fa/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright 2014-2018 Phil, Antonio Carlos Ribeiro and All Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
415
admin/phpMyAdmin/vendor/pragmarx/google2fa/README.md
vendored
Normal file
415
admin/phpMyAdmin/vendor/pragmarx/google2fa/README.md
vendored
Normal file
|
@ -0,0 +1,415 @@
|
|||
# Google2FA
|
||||
## Google Two-Factor Authentication for PHP
|
||||
|
||||
Google2FA is a PHP implementation of the Google Two-Factor Authentication Module, supporting the HMAC-Based One-time Password (HOTP) algorithm specified in [RFC 4226](https://tools.ietf.org/html/rfc4226) and the Time-based One-time Password (TOTP) algorithm specified in [RFC 6238](https://tools.ietf.org/html/rfc6238).
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/pragmarx/google2fa"><img alt="Latest Stable Version" src="https://img.shields.io/packagist/v/pragmarx/google2fa.svg?style=flat-square"></a>
|
||||
<a href="LICENSE.md"><img alt="License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
|
||||
<a href="https://scrutinizer-ci.com/g/antonioribeiro/google2fa/?branch=master"><img alt="Code Quality" src="https://img.shields.io/scrutinizer/g/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
<a href="https://travis-ci.org/antonioribeiro/google2fa"><img alt="Build" src="https://img.shields.io/travis/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
<a href="https://packagist.org/packages/pragmarx/google2fa"><img alt="Downloads" src="https://img.shields.io/packagist/dt/pragmarx/google2fa.svg?style=flat-square"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://packagist.org/packages/pragmarx/google2fa"><img alt="Monthly Downloads" src="https://poser.pugx.org/pragmarx/google2fa/d/monthly?format=flat-square"></a>
|
||||
<a href="https://scrutinizer-ci.com/g/antonioribeiro/google2fa/?branch=master"><img alt="Coverage" src="https://img.shields.io/scrutinizer/coverage/g/antonioribeiro/google2fa.svg?style=flat-square"></a>
|
||||
<a href="https://travis-ci.org/antonioribeiro/google2fa"><img alt="PHP" src="https://img.shields.io/badge/PHP-7.1%20--%208.0-brightgreen.svg?style=flat-square"></a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## Menu
|
||||
|
||||
- [Version Compatibility](#version-compatibility)
|
||||
- [Google Two-Factor Authentication for PHP](#google-two-factor-authentication-for-php)
|
||||
- [Laravel bridge](#laravel-bridge)
|
||||
- [Demos, Example & Playground](#demos-example--playground)
|
||||
- [Requirements](#requirements)
|
||||
- [Installing](#installing)
|
||||
- [Usage](#usage)
|
||||
- [How To Generate And Use Two Factor Authentication](#how-to-generate-and-use-two-factor-authentication)
|
||||
- [Generating QRCodes](#generating-qrcodes)
|
||||
- [QR Code Packages](#qr-code-packages)
|
||||
- [Examples of Usage](#examples-of-usage)
|
||||
- [HMAC Algorithms](#hmac-algorithms)
|
||||
- [Server Time](#server-time)
|
||||
- [Validation Window](#validation-window)
|
||||
- [Using a Bigger and Prefixing the Secret Key](#using-a-bigger-and-prefixing-the-secret-key)
|
||||
- [Google Authenticator secret key compatibility](#google-authenticator-secret-key-compatibility)
|
||||
- [Google Authenticator Apps](#google-authenticator-apps)
|
||||
- [Deprecation Warning](#deprecation-warning)
|
||||
- [Testing](#testing)
|
||||
- [Authors](#authors)
|
||||
- [License](#license)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## Version Compatibility
|
||||
|
||||
PHP | Google2FA
|
||||
:--------|:----------
|
||||
5.4 | 7.x LTS
|
||||
5.5 | 7.x LTS
|
||||
5.6 | 7.x LTS
|
||||
7.1 | 8.x
|
||||
7.2 | 8.x
|
||||
7.3 | 8.x
|
||||
7.4 | 8.x
|
||||
8.0 (β) | 8.x
|
||||
|
||||
## Laravel bridge
|
||||
|
||||
This package is agnostic, but there's a [Laravel bridge](https://github.com/antonioribeiro/google2fa-laravel).
|
||||
|
||||
## About QRCode generation
|
||||
|
||||
This package does not generate QRCodes for 2FA.
|
||||
|
||||
If you are looking for Google Two-Factor Authentication, but also need to generate QRCode for it, you can use the [Google2FA QRCode package](https://github.com/antonioribeiro/google2fa-qrcode), which integrates this package and also generates QRCodes using the BaconQRCode library, or check options on how to do it yourself [here in the docs](#qr-code-packages).
|
||||
|
||||
## Demos, Example & Playground
|
||||
|
||||
Please check the [Google2FA Package Playground](http://pragmarx.com/playground/google2fa).
|
||||
|
||||

|
||||
|
||||
Here's an demo app showing how to use Google2FA: [google2fa-example](https://github.com/antonioribeiro/google2fa-example).
|
||||
|
||||
You can scan the QR code on [this (old) demo page](https://antoniocarlosribeiro.com/technology/google2fa) with a Google Authenticator app and view the code changing (almost) in real time.
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 7.1 or greater
|
||||
|
||||
## Installing
|
||||
|
||||
Use Composer to install it:
|
||||
|
||||
composer require pragmarx/google2fa
|
||||
|
||||
To generate inline QRCodes, you'll need to install a QR code generator, e.g. [BaconQrCode](https://github.com/Bacon/BaconQrCode):
|
||||
|
||||
composer require bacon/bacon-qr-code
|
||||
|
||||
## Usage
|
||||
|
||||
### Instantiate it directly
|
||||
|
||||
```php
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
|
||||
$google2fa = new Google2FA();
|
||||
|
||||
return $google2fa->generateSecretKey();
|
||||
```
|
||||
|
||||
## How To Generate And Use Two Factor Authentication
|
||||
|
||||
Generate a secret key for your user and save it:
|
||||
|
||||
```php
|
||||
$user->google2fa_secret = $google2fa->generateSecretKey();
|
||||
```
|
||||
|
||||
## Generating QRCodes
|
||||
|
||||
The securer way of creating QRCode is to do it yourself or using a library. First you have to install a QR code generator e.g. BaconQrCode, as stated above, then you just have to generate the QR code url using:
|
||||
|
||||
```php
|
||||
$qrCodeUrl = $google2fa->getQRCodeUrl(
|
||||
$companyName,
|
||||
$companyEmail,
|
||||
$secretKey
|
||||
);
|
||||
```
|
||||
|
||||
Once you have the QR code url, you can feed it to your preferred QR code generator.
|
||||
|
||||
```php
|
||||
// Use your own QR Code generator to generate a data URL:
|
||||
$google2fa_url = custom_generate_qrcode_url($qrCodeUrl);
|
||||
|
||||
/// and in your view:
|
||||
|
||||
<img src="{{ $google2fa_url }}" alt="">
|
||||
```
|
||||
|
||||
And to verify, you just have to:
|
||||
|
||||
```php
|
||||
$secret = $request->input('secret');
|
||||
|
||||
$valid = $google2fa->verifyKey($user->google2fa_secret, $secret);
|
||||
```
|
||||
|
||||
## QR Code Packages
|
||||
|
||||
This package suggests the use of [Bacon/QRCode](https://github.com/Bacon/BaconQrCode) because
|
||||
it is known as a good QR Code package, but you can use it with any other package, for
|
||||
instance [Google2FA QRCode](https://github.com/antonioribeiro/google2fa-qrcode),
|
||||
[Simple QrCode](https://www.simplesoftware.io/docs/simple-qrcode)
|
||||
or [Endroid QR Code](https://github.com/endroid/qr-code), all of them use
|
||||
[Bacon/QRCode](https://github.com/Bacon/BaconQrCode) to produce QR Codes.
|
||||
|
||||
Usually you'll need a 2FA URL, so you just have to use the URL generator:
|
||||
|
||||
```php
|
||||
$google2fa->getQRCodeUrl($companyName, $companyEmail, $secretKey)
|
||||
```
|
||||
|
||||
## Examples of Usage
|
||||
|
||||
### [Google2FA QRCode](https://github.com/antonioribeiro/google2fa-qrcode)
|
||||
|
||||
Get a QRCode to be used inline:
|
||||
|
||||
```php
|
||||
$google2fa = (new \PragmaRX\Google2FAQRCode\Google2FA());
|
||||
|
||||
$inlineUrl = $google2fa->getQRCodeInline(
|
||||
'Company Name',
|
||||
'company@email.com',
|
||||
$google2fa->generateSecretKey()
|
||||
);
|
||||
```
|
||||
|
||||
And use in your template:
|
||||
|
||||
```php
|
||||
<img src="{{ $inlineUrl }}">
|
||||
```
|
||||
|
||||
### [Simple QrCode](https://www.simplesoftware.io/docs/simple-qrcode)
|
||||
|
||||
```php
|
||||
<div class="visible-print text-center">
|
||||
{!! QrCode::size(100)->generate($google2fa->getQRCodeUrl($companyName, $companyEmail, $secretKey)); !!}
|
||||
<p>Scan me to return to the original page.</p>
|
||||
</div>
|
||||
```
|
||||
|
||||
### [Endroid QR Code Generator](https://github.com/endroid/qr-code)
|
||||
|
||||
Generate the data URL
|
||||
|
||||
```php
|
||||
|
||||
$qrCode = new \Endroid\QrCode\QrCode($value);
|
||||
$qrCode->setSize(100);
|
||||
$google2fa_url = $qrCode->writeDataUri();
|
||||
```
|
||||
|
||||
And in your view
|
||||
|
||||
```php
|
||||
<div class="visible-print text-center">
|
||||
{!! $google2fa_url !!}
|
||||
<p>Scan me to return to the original page.</p>
|
||||
</div>
|
||||
```
|
||||
|
||||
### [Bacon/QRCode](https://github.com/Bacon/BaconQrCode)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
|
||||
$google2fa = app(Google2FA::class);
|
||||
|
||||
$g2faUrl = $google2fa->getQRCodeUrl(
|
||||
'pragmarx',
|
||||
'google2fa@pragmarx.com',
|
||||
$google2fa->generateSecretKey()
|
||||
);
|
||||
|
||||
$writer = new Writer(
|
||||
new ImageRenderer(
|
||||
new RendererStyle(400),
|
||||
new ImagickImageBackEnd()
|
||||
)
|
||||
);
|
||||
|
||||
$qrcode_image = base64_encode($writer->writeString($g2faUrl));
|
||||
```
|
||||
|
||||
And show it as an image:
|
||||
|
||||
```php
|
||||
<img src="data:image/png;base64, <?php echo $qrcode_image; ?> "/>
|
||||
```
|
||||
|
||||
## HMAC Algorithms
|
||||
|
||||
To comply with [RFC6238](https://tools.ietf.org/html/rfc6238), this package supports SHA1, SHA256 and SHA512. It defaults to SHA1, so to use a different algorithm you just have to use the method `setAlgorith()`:
|
||||
|
||||
``` php
|
||||
|
||||
use PragmaRX\Google2FA\Support\Constants;
|
||||
|
||||
$google2fa->setAlgorithm(Constants::SHA512);
|
||||
```
|
||||
|
||||
## Server Time
|
||||
|
||||
It's really important that you keep your server time in sync with some NTP server, on Ubuntu you can add this to the crontab:
|
||||
|
||||
```bash
|
||||
sudo service ntp stop
|
||||
sudo ntpd -gq
|
||||
sudo service ntp start
|
||||
```
|
||||
|
||||
## Validation Window
|
||||
|
||||
To avoid problems with clocks that are slightly out of sync, we do not check against the current key only but also consider `$window` keys each from the past and future. You can pass `$window` as optional third parameter to `verifyKey`, it defaults to `4`. A new key is generated every 30 seconds, so this window includes keys from the previous two and next two minutes.
|
||||
|
||||
```php
|
||||
$secret = $request->input('secret');
|
||||
|
||||
$window = 8; // 8 keys (respectively 4 minutes) past and future
|
||||
|
||||
$valid = $google2fa->verifyKey($user->google2fa_secret, $secret, $window);
|
||||
```
|
||||
|
||||
An attacker might be able to watch the user entering his credentials and one time key.
|
||||
Without further precautions, the key remains valid until it is no longer within the window of the server time. In order to prevent usage of a one time key that has already been used, you can utilize the `verifyKeyNewer` function.
|
||||
|
||||
```php
|
||||
$secret = $request->input('secret');
|
||||
|
||||
$timestamp = $google2fa->verifyKeyNewer($user->google2fa_secret, $secret, $user->google2fa_ts);
|
||||
|
||||
if ($timestamp !== false) {
|
||||
$user->update(['google2fa_ts' => $timestamp]);
|
||||
// successful
|
||||
} else {
|
||||
// failed
|
||||
}
|
||||
```
|
||||
|
||||
Note that `$timestamp` either `false` (if the key is invalid or has been used before) or the provided key's unix timestamp divided by the key regeneration period of 30 seconds.
|
||||
|
||||
## Using a Bigger and Prefixing the Secret Key
|
||||
|
||||
Although the probability of collision of a 16 bytes (128 bits) random string is very low, you can harden it by:
|
||||
|
||||
#### Use a bigger key
|
||||
|
||||
```php
|
||||
$secretKey = $google2fa->generateSecretKey(32); // defaults to 16 bytes
|
||||
```
|
||||
|
||||
#### You can prefix your secret keys
|
||||
|
||||
You may prefix your secret keys, but you have to understand that, as your secret key must have length in power of 2, your prefix will have to have a complementary size. So if your key is 16 bytes long, if you add a prefix it must be also 16 bytes long, but as your prefixes will be converted to base 32, the max length of your prefix is 10 bytes. So, those are the sizes you can use in your prefixes:
|
||||
|
||||
```
|
||||
1, 2, 5, 10, 20, 40, 80...
|
||||
```
|
||||
|
||||
And it can be used like so:
|
||||
|
||||
```php
|
||||
$prefix = strpad($userId, 10, 'X');
|
||||
|
||||
$secretKey = $google2fa->generateSecretKey(16, $prefix);
|
||||
```
|
||||
|
||||
#### Window
|
||||
|
||||
The Window property defines how long a OTP will work, or how many cycles it will last. A key has a 30 seconds cycle, setting the window to 0 will make the key lasts for those 30 seconds, setting it to 2 will make it last for 120 seconds. This is how you set the window:
|
||||
|
||||
```php
|
||||
$secretKey = $google2fa->setWindow(4);
|
||||
```
|
||||
|
||||
But you can also set the window while checking the key. If you need to set a window of 4 during key verification, this is how you do:
|
||||
|
||||
```php
|
||||
$isValid = $google2fa->verifyKey($seed, $key, 4);
|
||||
```
|
||||
|
||||
#### Key Regeneration Interval
|
||||
|
||||
You can change key regeneration interval, which defaults to 30 seconds, but remember that this is a default value on most authentication apps, like Google Authenticator, which will, basically, make your app out of sync with them.
|
||||
|
||||
```php
|
||||
$google2fa->setKeyRegeneration(40);
|
||||
```
|
||||
|
||||
## Google Authenticator secret key compatibility
|
||||
|
||||
To be compatible with Google Authenticator, your (converted to base 32) secret key length must be at least 8 chars and be a power of 2: 8, 16, 32, 64...
|
||||
|
||||
So, to prevent errors, you can do something like this while generating it:
|
||||
|
||||
```php
|
||||
$secretKey = '123456789';
|
||||
|
||||
$secretKey = str_pad($secretKey, pow(2,ceil(log(strlen($secretKey),2))), 'X');
|
||||
```
|
||||
|
||||
And it will generate
|
||||
|
||||
```
|
||||
123456789XXXXXXX
|
||||
```
|
||||
|
||||
By default, this package will enforce compatibility, but, if Google Authenticator is not a target, you can disable it by doing
|
||||
|
||||
```php
|
||||
$google2fa->setEnforceGoogleAuthenticatorCompatibility(false);
|
||||
```
|
||||
|
||||
## Google Authenticator Apps
|
||||
|
||||
To use the two factor authentication, your user will have to install a Google Authenticator compatible app, those are some of the currently available:
|
||||
|
||||
* [Authy for iOS, Android, Chrome, OS X](https://www.authy.com/)
|
||||
* [FreeOTP for iOS, Android and Pebble](https://apps.getpebble.com/en_US/application/52f1a4c3c4117252f9000bb8)
|
||||
* [Google Authenticator for iOS](https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8)
|
||||
* [Google Authenticator for Android](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2)
|
||||
* [Google Authenticator (port) on Windows Store](https://www.microsoft.com/en-us/store/p/google-authenticator/9wzdncrdnkrf)
|
||||
* [Microsoft Authenticator for Windows Phone](https://www.microsoft.com/en-us/store/apps/authenticator/9wzdncrfj3rj)
|
||||
* [LastPass Authenticator for iOS, Android, OS X, Windows](https://lastpass.com/auth/)
|
||||
* [1Password for iOS, Android, OS X, Windows](https://1password.com)
|
||||
|
||||
## Deprecation Warning
|
||||
|
||||
Google API for QR generator is turned off. All version of that package prior to 5.0.0 are deprecated. Please upgrade and check documentation regarding [QRCode generation](https://github.com/antonioribeiro/google2fa#generating-qrcodes).
|
||||
|
||||
## Testing
|
||||
|
||||
The package tests were written with [PHPUnit](https://phpunit.de/). There are some Composer scripts to help you run tests and analysis:
|
||||
|
||||
PHPUnit:
|
||||
|
||||
````
|
||||
composer test
|
||||
````
|
||||
|
||||
PHPStan analysis:
|
||||
|
||||
````
|
||||
composer analyse
|
||||
````
|
||||
|
||||
## Authors
|
||||
|
||||
- [Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)
|
||||
- [Phil (Orginal author of this class)](https://www.idontplaydarts.com/static/ga.php_.txt)
|
||||
- [All Contributors](https://github.com/antonioribeiro/google2fa/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
Google2FA is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and issues are more than welcome.
|
43
admin/phpMyAdmin/vendor/pragmarx/google2fa/composer.json
vendored
Normal file
43
admin/phpMyAdmin/vendor/pragmarx/google2fa/composer.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "pragmarx/google2fa",
|
||||
"description": "A One Time Password Authentication package, compatible with Google Authenticator.",
|
||||
"keywords": [
|
||||
"authentication",
|
||||
"two factor authentication",
|
||||
"google2fa",
|
||||
"2fa"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Antonio Carlos Ribeiro",
|
||||
"email": "acr@antoniocarlosribeiro.com",
|
||||
"role": "Creator & Designer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1|^8.0",
|
||||
"paragonie/constant_time_encoding": "^1.0|^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5.15|^8.5|^9.0",
|
||||
"phpstan/phpstan": "^0.12.18"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PragmaRX\\Google2FA\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"PragmaRX\\Google2FA\\Tests\\": "tests/"
|
||||
},
|
||||
"files": ["tests/helpers.php"]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "bash ./tests/tools/test.sh",
|
||||
"analyse": "bash ./tests/tools/analyse.sh"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/Google2FA.php
vendored
Normal file
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/Google2FA.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions\Contracts;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface Google2FA extends Throwable
|
||||
{
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions\Contracts;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface IncompatibleWithGoogleAuthenticator extends Throwable
|
||||
{
|
||||
}
|
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/InvalidAlgorithm.php
vendored
Normal file
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/InvalidAlgorithm.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions\Contracts;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface InvalidAlgorithm extends Throwable
|
||||
{
|
||||
}
|
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/InvalidCharacters.php
vendored
Normal file
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/InvalidCharacters.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions\Contracts;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface InvalidCharacters extends Throwable
|
||||
{
|
||||
}
|
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/SecretKeyTooShort.php
vendored
Normal file
9
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Contracts/SecretKeyTooShort.php
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions\Contracts;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface SecretKeyTooShort extends Throwable
|
||||
{
|
||||
}
|
10
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Google2FAException.php
vendored
Normal file
10
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/Google2FAException.php
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\Google2FA as Google2FAExceptionContract;
|
||||
|
||||
class Google2FAException extends Exception implements Google2FAExceptionContract
|
||||
{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions;
|
||||
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\Google2FA as Google2FAExceptionContract;
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\IncompatibleWithGoogleAuthenticator as IncompatibleWithGoogleAuthenticatorExceptionContract;
|
||||
|
||||
class IncompatibleWithGoogleAuthenticatorException extends Google2FAException implements Google2FAExceptionContract, IncompatibleWithGoogleAuthenticatorExceptionContract
|
||||
{
|
||||
protected $message = 'This secret key is not compatible with Google Authenticator.';
|
||||
}
|
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/InvalidAlgorithmException.php
vendored
Normal file
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/InvalidAlgorithmException.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions;
|
||||
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\Google2FA as Google2FAExceptionContract;
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\InvalidAlgorithm as InvalidAlgorithmExceptionContract;
|
||||
|
||||
class InvalidAlgorithmException extends Google2FAException implements Google2FAExceptionContract, InvalidAlgorithmExceptionContract
|
||||
{
|
||||
protected $message = 'Invalid HMAC algorithm.';
|
||||
}
|
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/InvalidCharactersException.php
vendored
Normal file
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/InvalidCharactersException.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions;
|
||||
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\Google2FA as Google2FAExceptionContract;
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\InvalidCharacters as InvalidCharactersExceptionContract;
|
||||
|
||||
class InvalidCharactersException extends Google2FAException implements Google2FAExceptionContract, InvalidCharactersExceptionContract
|
||||
{
|
||||
protected $message = 'Invalid characters in the base32 string.';
|
||||
}
|
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/SecretKeyTooShortException.php
vendored
Normal file
11
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Exceptions/SecretKeyTooShortException.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Exceptions;
|
||||
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\Google2FA as Google2FAExceptionContract;
|
||||
use PragmaRX\Google2FA\Exceptions\Contracts\SecretKeyTooShort as SecretKeyTooShortExceptionContract;
|
||||
|
||||
class SecretKeyTooShortException extends Google2FAException implements Google2FAExceptionContract, SecretKeyTooShortExceptionContract
|
||||
{
|
||||
protected $message = 'Secret key is too short. Must be at least 16 base32 characters';
|
||||
}
|
495
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Google2FA.php
vendored
Normal file
495
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Google2FA.php
vendored
Normal file
|
@ -0,0 +1,495 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA;
|
||||
|
||||
use PragmaRX\Google2FA\Exceptions\InvalidAlgorithmException;
|
||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||
use PragmaRX\Google2FA\Support\Base32;
|
||||
use PragmaRX\Google2FA\Support\Constants;
|
||||
use PragmaRX\Google2FA\Support\QRCode;
|
||||
|
||||
class Google2FA
|
||||
{
|
||||
use QRCode;
|
||||
use Base32;
|
||||
|
||||
/**
|
||||
* Algorithm.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $algorithm = Constants::SHA1;
|
||||
|
||||
/**
|
||||
* Length of the Token generated.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $oneTimePasswordLength = 6;
|
||||
|
||||
/**
|
||||
* Interval between key regeneration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $keyRegeneration = 30;
|
||||
|
||||
/**
|
||||
* Secret.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $secret;
|
||||
|
||||
/**
|
||||
* Window.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $window = 1; // Keys will be valid for 60 seconds
|
||||
|
||||
/**
|
||||
* Find a valid One Time Password.
|
||||
*
|
||||
* @param string $secret
|
||||
* @param string $key
|
||||
* @param int|null $window
|
||||
* @param int $startingTimestamp
|
||||
* @param int $timestamp
|
||||
* @param int|null $oldTimestamp
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function findValidOTP(
|
||||
$secret,
|
||||
$key,
|
||||
$window,
|
||||
$startingTimestamp,
|
||||
$timestamp,
|
||||
$oldTimestamp = null
|
||||
) {
|
||||
for (;
|
||||
$startingTimestamp <= $timestamp + $this->getWindow($window);
|
||||
$startingTimestamp++
|
||||
) {
|
||||
if (
|
||||
hash_equals($this->oathTotp($secret, $startingTimestamp), $key)
|
||||
) {
|
||||
return is_null($oldTimestamp)
|
||||
? true
|
||||
: $startingTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the HMAC OTP.
|
||||
*
|
||||
* @param string $secret
|
||||
* @param int $counter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateHotp($secret, $counter)
|
||||
{
|
||||
return hash_hmac(
|
||||
$this->getAlgorithm(),
|
||||
pack('N*', 0, $counter), // Counter must be 64-bit int
|
||||
$secret,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a digit secret key in base32 format.
|
||||
*
|
||||
* @param int $length
|
||||
* @param string $prefix
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateSecretKey($length = 16, $prefix = '')
|
||||
{
|
||||
return $this->generateBase32RandomKey($length, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current one time password for a key.
|
||||
*
|
||||
* @param string $secret
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentOtp($secret)
|
||||
{
|
||||
return $this->oathTotp($secret, $this->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HMAC algorithm.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlgorithm()
|
||||
{
|
||||
return $this->algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key regeneration.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getKeyRegeneration()
|
||||
{
|
||||
return $this->keyRegeneration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OTP length.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOneTimePasswordLength()
|
||||
{
|
||||
return $this->oneTimePasswordLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get secret.
|
||||
*
|
||||
* @param string|null $secret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecret($secret = null)
|
||||
{
|
||||
return is_null($secret) ? $this->secret : $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current Unix Timestamp divided by the $keyRegeneration
|
||||
* period.
|
||||
*
|
||||
* @return int
|
||||
**/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return (int) floor(microtime(true) / $this->keyRegeneration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of valid HMAC algorithms.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getValidAlgorithms()
|
||||
{
|
||||
return [
|
||||
Constants::SHA1,
|
||||
Constants::SHA256,
|
||||
Constants::SHA512,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the OTP window.
|
||||
*
|
||||
* @param null|int $window
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWindow($window = null)
|
||||
{
|
||||
return is_null($window) ? $this->window : $window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a window based starting timestamp.
|
||||
*
|
||||
* @param int|null $window
|
||||
* @param int $timestamp
|
||||
* @param int|null $oldTimestamp
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function makeStartingTimestamp($window, $timestamp, $oldTimestamp = null)
|
||||
{
|
||||
return is_null($oldTimestamp)
|
||||
? $timestamp - $this->getWindow($window)
|
||||
: max($timestamp - $this->getWindow($window), $oldTimestamp + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/use a starting timestamp for key verification.
|
||||
*
|
||||
* @param string|int|null $timestamp
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function makeTimestamp($timestamp = null)
|
||||
{
|
||||
if (is_null($timestamp)) {
|
||||
return $this->getTimestamp();
|
||||
}
|
||||
|
||||
return (int) $timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the secret key and the timestamp and returns the one time
|
||||
* password.
|
||||
*
|
||||
* @param string $secret Secret key in binary form.
|
||||
* @param int $counter Timestamp as returned by getTimestamp.
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function oathTotp($secret, $counter)
|
||||
{
|
||||
if (strlen($secret) < 8) {
|
||||
throw new SecretKeyTooShortException();
|
||||
}
|
||||
|
||||
$secret = $this->base32Decode($this->getSecret($secret));
|
||||
|
||||
return str_pad(
|
||||
$this->oathTruncate($this->generateHotp($secret, $counter)),
|
||||
$this->getOneTimePasswordLength(),
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the OTP from the SHA1 hash.
|
||||
*
|
||||
* @param string $hash
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public function oathTruncate($hash)
|
||||
{
|
||||
$offset = ord($hash[strlen($hash) - 1]) & 0xF;
|
||||
|
||||
$temp = unpack('N', substr($hash, $offset, 4));
|
||||
|
||||
$temp = $temp[1] & 0x7FFFFFFF;
|
||||
|
||||
return substr(
|
||||
(string) $temp,
|
||||
-$this->getOneTimePasswordLength()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove invalid chars from a base 32 string.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function removeInvalidChars($string)
|
||||
{
|
||||
return preg_replace(
|
||||
'/[^'.Constants::VALID_FOR_B32.']/',
|
||||
'',
|
||||
$string
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the enforce Google Authenticator compatibility property.
|
||||
*
|
||||
* @param mixed $enforceGoogleAuthenticatorCompatibility
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnforceGoogleAuthenticatorCompatibility(
|
||||
$enforceGoogleAuthenticatorCompatibility
|
||||
) {
|
||||
$this->enforceGoogleAuthenticatorCompatibility = $enforceGoogleAuthenticatorCompatibility;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HMAC hashing algorithm.
|
||||
*
|
||||
* @param mixed $algorithm
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidAlgorithmException
|
||||
*
|
||||
* @return \PragmaRX\Google2FA\Google2FA
|
||||
*/
|
||||
public function setAlgorithm($algorithm)
|
||||
{
|
||||
// Default to SHA1 HMAC algorithm
|
||||
if (!in_array($algorithm, $this->getValidAlgorithms())) {
|
||||
throw new InvalidAlgorithmException();
|
||||
}
|
||||
|
||||
$this->algorithm = $algorithm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set key regeneration.
|
||||
*
|
||||
* @param mixed $keyRegeneration
|
||||
*/
|
||||
public function setKeyRegeneration($keyRegeneration)
|
||||
{
|
||||
$this->keyRegeneration = $keyRegeneration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OTP length.
|
||||
*
|
||||
* @param mixed $oneTimePasswordLength
|
||||
*/
|
||||
public function setOneTimePasswordLength($oneTimePasswordLength)
|
||||
{
|
||||
$this->oneTimePasswordLength = $oneTimePasswordLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set secret.
|
||||
*
|
||||
* @param mixed $secret
|
||||
*/
|
||||
public function setSecret($secret)
|
||||
{
|
||||
$this->secret = $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the OTP window.
|
||||
*
|
||||
* @param mixed $window
|
||||
*/
|
||||
public function setWindow($window)
|
||||
{
|
||||
$this->window = $window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a user inputted key against the current timestamp. Checks $window
|
||||
* keys either side of the timestamp.
|
||||
*
|
||||
* @param string $key User specified key
|
||||
* @param string $secret
|
||||
* @param null|int $window
|
||||
* @param null|int $timestamp
|
||||
* @param null|int $oldTimestamp
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function verify(
|
||||
$key,
|
||||
$secret,
|
||||
$window = null,
|
||||
$timestamp = null,
|
||||
$oldTimestamp = null
|
||||
) {
|
||||
return $this->verifyKey(
|
||||
$secret,
|
||||
$key,
|
||||
$window,
|
||||
$timestamp,
|
||||
$oldTimestamp
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a user inputted key against the current timestamp. Checks $window
|
||||
* keys either side of the timestamp.
|
||||
*
|
||||
* @param string $secret
|
||||
* @param string $key User specified key
|
||||
* @param int|null $window
|
||||
* @param null|int $timestamp
|
||||
* @param null|int $oldTimestamp
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function verifyKey(
|
||||
$secret,
|
||||
$key,
|
||||
$window = null,
|
||||
$timestamp = null,
|
||||
$oldTimestamp = null
|
||||
) {
|
||||
$timestamp = $this->makeTimestamp($timestamp);
|
||||
|
||||
return $this->findValidOTP(
|
||||
$secret,
|
||||
$key,
|
||||
$window,
|
||||
$this->makeStartingTimestamp($window, $timestamp, $oldTimestamp),
|
||||
$timestamp,
|
||||
$oldTimestamp
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a user inputted key against the current timestamp. Checks $window
|
||||
* keys either side of the timestamp, but ensures that the given key is newer than
|
||||
* the given oldTimestamp. Useful if you need to ensure that a single key cannot
|
||||
* be used twice.
|
||||
*
|
||||
* @param string $secret
|
||||
* @param string $key User specified key
|
||||
* @param int|null $oldTimestamp The timestamp from the last verified key
|
||||
* @param int|null $window
|
||||
* @param int|null $timestamp
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function verifyKeyNewer(
|
||||
$secret,
|
||||
$key,
|
||||
$oldTimestamp,
|
||||
$window = null,
|
||||
$timestamp = null
|
||||
) {
|
||||
return $this->verifyKey(
|
||||
$secret,
|
||||
$key,
|
||||
$window,
|
||||
$timestamp,
|
||||
$oldTimestamp
|
||||
);
|
||||
}
|
||||
}
|
208
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/Base32.php
vendored
Normal file
208
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/Base32.php
vendored
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Support;
|
||||
|
||||
use ParagonIE\ConstantTime\Base32 as ParagonieBase32;
|
||||
use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;
|
||||
use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
|
||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||
|
||||
trait Base32
|
||||
{
|
||||
/**
|
||||
* Enforce Google Authenticator compatibility.
|
||||
*/
|
||||
protected $enforceGoogleAuthenticatorCompatibility = true;
|
||||
|
||||
/**
|
||||
* Calculate char count bits.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function charCountBits($b32)
|
||||
{
|
||||
return strlen($b32) * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a digit secret key in base32 format.
|
||||
*
|
||||
* @param int $length
|
||||
* @param string $prefix
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateBase32RandomKey($length = 16, $prefix = '')
|
||||
{
|
||||
$secret = $prefix ? $this->toBase32($prefix) : '';
|
||||
|
||||
$secret = $this->strPadBase32($secret, $length);
|
||||
|
||||
$this->validateSecret($secret);
|
||||
|
||||
return $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a base32 string into a binary string.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function base32Decode($b32)
|
||||
{
|
||||
$b32 = strtoupper($b32);
|
||||
|
||||
$this->validateSecret($b32);
|
||||
|
||||
return ParagonieBase32::decodeUpper($b32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the string length is power of two.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isCharCountNotAPowerOfTwo($b32)
|
||||
{
|
||||
return (strlen($b32) & (strlen($b32) - 1)) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pad string with random base 32 chars.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $length
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function strPadBase32($string, $length)
|
||||
{
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$string .= substr(
|
||||
Constants::VALID_FOR_B32_SCRAMBLED,
|
||||
$this->getRandomNumber(),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a string to Base32.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toBase32($string)
|
||||
{
|
||||
$encoded = ParagonieBase32::encodeUpper($string);
|
||||
|
||||
return str_replace('=', '', $encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random number.
|
||||
*
|
||||
* @param int $from
|
||||
* @param int $to
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getRandomNumber($from = 0, $to = 31)
|
||||
{
|
||||
return random_int($from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the secret.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
*/
|
||||
protected function validateSecret($b32)
|
||||
{
|
||||
$this->checkForValidCharacters($b32);
|
||||
|
||||
$this->checkGoogleAuthenticatorCompatibility($b32);
|
||||
|
||||
$this->checkIsBigEnough($b32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the secret key is compatible with Google Authenticator.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @throws IncompatibleWithGoogleAuthenticatorException
|
||||
*/
|
||||
protected function checkGoogleAuthenticatorCompatibility($b32)
|
||||
{
|
||||
if (
|
||||
$this->enforceGoogleAuthenticatorCompatibility &&
|
||||
$this->isCharCountNotAPowerOfTwo($b32) // Google Authenticator requires it to be a power of 2 base32 length string
|
||||
) {
|
||||
throw new IncompatibleWithGoogleAuthenticatorException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all secret key characters are valid.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
*/
|
||||
protected function checkForValidCharacters($b32)
|
||||
{
|
||||
if (
|
||||
preg_replace('/[^'.Constants::VALID_FOR_B32.']/', '', $b32) !==
|
||||
$b32
|
||||
) {
|
||||
throw new InvalidCharactersException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if secret key length is big enough.
|
||||
*
|
||||
* @param string $b32
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
*/
|
||||
protected function checkIsBigEnough($b32)
|
||||
{
|
||||
// Minimum = 128 bits
|
||||
// Recommended = 160 bits
|
||||
// Compatible with Google Authenticator = 256 bits
|
||||
|
||||
if (
|
||||
$this->charCountBits($b32) < 128
|
||||
) {
|
||||
throw new SecretKeyTooShortException();
|
||||
}
|
||||
}
|
||||
}
|
31
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/Constants.php
vendored
Normal file
31
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/Constants.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Support;
|
||||
|
||||
class Constants
|
||||
{
|
||||
/**
|
||||
* Characters valid for Base 32.
|
||||
*/
|
||||
const VALID_FOR_B32 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
|
||||
/**
|
||||
* Characters valid for Base 32, scrambled.
|
||||
*/
|
||||
const VALID_FOR_B32_SCRAMBLED = '234567QWERTYUIOPASDFGHJKLZXCVBNM';
|
||||
|
||||
/**
|
||||
* SHA1 algorithm.
|
||||
*/
|
||||
const SHA1 = 'sha1';
|
||||
|
||||
/**
|
||||
* SHA256 algorithm.
|
||||
*/
|
||||
const SHA256 = 'sha256';
|
||||
|
||||
/**
|
||||
* SHA512 algorithm.
|
||||
*/
|
||||
const SHA512 = 'sha512';
|
||||
}
|
34
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/QRCode.php
vendored
Normal file
34
admin/phpMyAdmin/vendor/pragmarx/google2fa/src/Support/QRCode.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace PragmaRX\Google2FA\Support;
|
||||
|
||||
trait QRCode
|
||||
{
|
||||
/**
|
||||
* Creates a QR code url.
|
||||
*
|
||||
* @param string $company
|
||||
* @param string $holder
|
||||
* @param string $secret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQRCodeUrl($company, $holder, $secret)
|
||||
{
|
||||
return 'otpauth://totp/'.
|
||||
rawurlencode($company).
|
||||
':'.
|
||||
rawurlencode($holder).
|
||||
'?secret='.
|
||||
$secret.
|
||||
'&issuer='.
|
||||
rawurlencode($company).
|
||||
'&algorithm='.
|
||||
rawurlencode(strtoupper($this->getAlgorithm())).
|
||||
'&digits='.
|
||||
rawurlencode(strtoupper((string) $this->getOneTimePasswordLength())).
|
||||
'&period='.
|
||||
rawurlencode(strtoupper((string) $this->getKeyRegeneration())).
|
||||
'';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue