xruff/totpauth
Composer 安装命令:
composer require xruff/totpauth
包简介
Nette extension for Time-Based One-Time Password Algorithm
README 文档
README
Nette extension for Time-Based One-Time Password Algorithm
Requirements
Package requires PHP 7.0 or higher
Installation
The best way to install XRuff/TotpAuth is using Composer:
$ composer require xruff/totpAuth
Scenario
- logged user activate 2FA in account settings:
- see QR core
- scan it with mobile application
- and click "Confirm Code" button
- next login to your application:
- user log in standard way (login + password...) and see second login page with form with one field
- provide code from Authenticator mobile aplication
- pass through if provided code is right
Documentation
Assumptions:
- create table
qrin database, use schema from filesql/qr.sql $user->indentityhave to contain propertiesidandusername
Configuration in config.neon.
extensions: totpAuth: XRuff\TotpAuth\DI\TotpAuthExtension totpAuth: issuer: NameOfMyApp # mandatory identityKey: login # optional, Default is 'login' eg $user->identity->login timeWindow: 1 # optional - time tolerance codeSize: '300x300' # optional - size ofgenerated QR code
Presenter:
use XRuff\TotpAuth\Auth; use Nette\Application\UI; class HomepagePresenter extends Nette\Application\UI\Presenter { /** @var Auth $auth */ public $auth; public function __construct(Auth $auth) { $this->auth = $auth; } public function renderDefault() { $this->template->qrCode = $this->auth->getQrBase64(); } public function handleSaveUrl() { $this->auth->saveSecret(); $this->redirect('this'); } public function handleResetUrl() { $this->auth->resetSecret(); $this->redirect('this'); } protected function createComponentCodeForm() { $form = new UI\Form; $form->addText('code', 'Code'); $form->addSubmit('submit', 'Auth me'); $form->onSuccess[] = [$this, 'codeFormSucceeded']; return $form; } public function codeFormSucceeded(UI\Form $form, $values) { if ($this->auth->verify($values->code)) { $this->flashMessage('Success!'); } else { $this->flashMessage('Wrong code.'); } $this->redirect('this'); } }
default.latte:
...
{if $qrCode}
<img src="{$qrCode|nocheck}" alt="">
<br>
<a n:href="saveUrl!" class="btn btn-success">Confirm Code (have been added to Mobile Authenticator App)</a>
{else}
{control codeForm}
<a n:href="resetUrl!" class="btn btn-success">Reset auth code</a>
{/if}
...
Repository https://github.com/XRuff/TotpAuth.
xruff/totpauth 适用场景与选型建议
xruff/totpauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 257 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「google」 「nette」 「component」 「qrcode」 「totp」 「qr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xruff/totpauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xruff/totpauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xruff/totpauth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
FSi DataSource Component
Nette Framework adapter for I18n package
Build forms from schema
Priveate for SkeekS CMS
Asynchronous MQTT client built on React
Form with datetime support and Bootstrap 4 form renderer
统计信息
- 总下载量: 257
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-31