在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):antonioribeiro/google2fa-qrcode开源软件地址(OpenSource Url):https://github.com/antonioribeiro/google2fa-qrcode开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Google2FA QRCodeQRCode For Google2FAThis is package is Goole2FA 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. Requirements
InstallingUse Composer to install it:
Using ItInstantiate it directlyuse PragmaRX\Google2FAQRCode\Google2FA;
$google2fa = new Google2FA();
return $google2fa->generateSecretKey(); Generating QRCodesThe 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: $inlineUrl = $google2fa->getQRCodeInline(
$companyName,
$companyEmail,
$secretKey
); And use it in your blade template this way: <img src="{{ $inlineUrl }}"> $secretKey = $google2fa->generateSecretKey(16, $userId); Show the QR Code to your user, via Google ApisIt's insecure to use it via Google Apis, so you have to enable it before using it. $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: $secret = $request->input('secret');
$valid = $google2fa->verifyKey($user->google2fa_secret, $secret); Replacing the QRCode rendering serviceIf you want to use a different service, you just have to $google2fa->setQrcodeService(new YourService())
->getQRCodeInline(
$companyName,
$companyEmail,
$secretKey
); Built-in QRCode rendering servicesBeginning on version 2.0 the rendering service is optional, so you have to manually install one of those packages in order to generate QRCodes:
Using a diffent image backend$google2fa->setQrcodeService(
new \PragmaRX\Google2FAQRCode\QRCode\Bacon(
new \BaconQrCode\Renderer\Image\SvgImageBackEnd()
)
);
// or
$google2fa = new Google2FA(
new Bacon(
new \BaconQrCode\Renderer\Image\SvgImageBackEnd()
)
); TestsThe package tests were written with PHPUnit. AuthorsLicenseGoogle2FAQRCode is licensed under the MIT License - see the LICENSE file for details. ContributingPull requests and issues are more than welcome. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论