PHPackages                             xruff/totpauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xruff/totpauth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

xruff/totpauth
==============

Nette extension for Time-Based One-Time Password Algorithm

v2.0.1(5y ago)0223MITPHP

Since Aug 31Pushed 5y ago2 watchersCompare

[ Source](https://github.com/XRuff/TotpAuth)[ Packagist](https://packagist.org/packages/xruff/totpauth)[ RSS](/packages/xruff-totpauth/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (10)Versions (4)Used By (0)

TotpAuth
========

[](#totpauth)

Nette extension for Time-Based One-Time Password Algorithm

Requirements
------------

[](#requirements)

Package requires PHP 7.0 or higher

- [tracy/tracy](https://github.com/tracy/tracy)
- [xruff/basedbmodel](https://github.com/xruff/basedbmodel)
- [oops/totp-authenticator](https://github.com/oops/totp-authenticator)
- [guzzlehttp/guzzle](https://github.com/oops/totp-authenticator)

Installation
------------

[](#installation)

The best way to install XRuff/TotpAuth is using [Composer](http://getcomposer.org/):

```
$ composer require xruff/totpAuth
```

Scenario
--------

[](#scenario)

- logged user activate 2FA in account settings:
    - see QR core
    - scan it with [mobile application](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=cs)
    - 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
-------------

[](#documentation)

Assumptions:

- create table `qr` in database, use schema from file `sql/qr.sql`
- `$user->indentity` have to contain properties `id` and `username`

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}

        Confirm Code (have been added to Mobile Authenticator App)
    {else}
        {control codeForm}
        Reset auth code
    {/if}
    ...
```

---

Repository .

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity65

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~501 days

Total

3

Last Release

2178d ago

Major Versions

v1.0.0 → v2.0.02020-05-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/2eadb96b627cd99367bb565aa4c6058b276146ec587a6ea9f81b1ce1642dca3c?d=identicon)[xruff](/maintainers/xruff)

---

Tags

2faauthenticationnettenette-componentnette-frameworkqrqrcodeqrcodeqrgooglenettetotpcomponentNette Framework

### Embed Badge

![Health badge](/badges/xruff-totpauth/health.svg)

```
[![Health](https://phpackages.com/badges/xruff-totpauth/health.svg)](https://phpackages.com/packages/xruff-totpauth)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[contributte/recaptcha

Google reCAPTCHA for Nette - Forms

421.3M4](/packages/contributte-recaptcha)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
