定制 tekintian/google-authenticator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tekintian/google-authenticator

Composer 安装命令:

composer require tekintian/google-authenticator

包简介

谷歌的两步验证PHP服务端,Google身份验证器 Google Authenticator PHP实现,Google Authenticator 2-factor authentication

README 文档

README

谷歌的两步验证PHP服务端,Google身份验证器 Google Authenticator PHP实现,自带二维码生成类库, 再也不用担心服务端密码泄露问题了!

PS: 本工具为安全类工具,$secret 为本工具安全的基础, 如果$secret 泄露,则本工具失去安全的意义! 网上其他类似工具使用的第三方API生成二维码的方式是极不安全的!!!

https://github.com/tekintian/google-authenticator

This PHP class can be used to interact with the Google Authenticator mobile app for 2-factor-authentication. This class can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret. It implements TOTP according to RFC6238

For a secure installation you have to make sure that used codes cannot be reused (replay-attack). You also need to limit the number of verifications, to fight against brute-force attacks. For example you could limit the amount of verifications to 10 tries within 10 minutes for one IP address (or IPv6 block). It depends on your environment.

Usage:

  • install dependency with composer
composer require tekintian/google-authenticator
  • usage example:
<?php
require_once __DIR__ . '/vendor/autoload.php';

$ga = new \tekintian\GoogleAuthenticator()
$secret = $ga->createSecret();
echo "Secret is: ".$secret."\n\n";

$qr = $ga->getQRCode('Tekin', $secret);
echo "Default return the base64 QR-Code img: ".$qr."\n\n";

$oneCode = $ga->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret':\n";

# $checkResult = $ga->verifyCode($secret, $oneCode, 2);    // 2 = 2*30sec clock tolerance  可以有1分钟的时间误差
$checkResult = $ga->verifyCode($secret, $oneCode, 0);    // 不允许有时间误差
if ($checkResult) {
    echo 'OK';
} else {
    echo 'FAILED';
}

Google Authenticator Android App 谷歌省份验证器安卓版下载

https://github.com/tekintian/google-authenticator/releases/download/app/com.google.android.apps.authenticator2.apk

base64 img qrcode

<img src="data:png;base64,iVBORw0KGgoAAA.......rkJggg==" alt="">

ps: 本工具类部分算法参考了 https://github.com/PHPGangsta/GoogleAuthenticator 在此表示感谢!

统计信息

  • 总下载量: 266
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-4-Clause
  • 更新时间: 2020-06-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固