{"id":15282179,"url":"https://github.com/xruff/totpauth","last_synced_at":"2026-04-04T20:32:46.045Z","repository":{"id":57084987,"uuid":"101937527","full_name":"XRuff/TotpAuth","owner":"XRuff","description":"Nette extension for Time-Based One-Time Password Algorithm","archived":false,"fork":false,"pushed_at":"2020-05-28T21:59:02.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T14:11:41.121Z","etag":null,"topics":["2fa","authentication","nette","nette-component","nette-framework","qr","qrcode"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XRuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-30T23:19:57.000Z","updated_at":"2024-01-15T08:27:39.000Z","dependencies_parsed_at":"2022-08-24T22:50:33.790Z","dependency_job_id":null,"html_url":"https://github.com/XRuff/TotpAuth","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRuff%2FTotpAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRuff%2FTotpAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRuff%2FTotpAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRuff%2FTotpAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XRuff","download_url":"https://codeload.github.com/XRuff/TotpAuth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245111952,"owners_count":20562512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2fa","authentication","nette","nette-component","nette-framework","qr","qrcode"],"created_at":"2024-09-30T14:19:15.922Z","updated_at":"2025-10-17T18:27:27.695Z","avatar_url":"https://github.com/XRuff.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"TotpAuth\n======\n\nNette extension for Time-Based One-Time Password Algorithm\n\n\nRequirements\n------------\n\nPackage requires PHP 7.0 or higher\n\n- [tracy/tracy](https://github.com/tracy/tracy)\n- [xruff/basedbmodel](https://github.com/xruff/basedbmodel)\n- [oops/totp-authenticator](https://github.com/oops/totp-authenticator)\n- [guzzlehttp/guzzle](https://github.com/oops/totp-authenticator)\n\nInstallation\n------------\n\nThe best way to install XRuff/TotpAuth is using  [Composer](http://getcomposer.org/):\n\n```sh\n$ composer require xruff/totpAuth\n```\n\nScenario\n------------\n\n\n* logged user activate 2FA in account settings:\n  * see QR core\n  * scan it with [mobile application](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\u0026hl=cs)\n  * and click \"Confirm Code\" button\n* next login to your application:\n  * user log in standard way (login + password...) and see second login page with form with one field\n  * provide code from Authenticator mobile aplication\n  * pass through if provided code is right\n\n\nDocumentation\n------------\n\nAssumptions:\n\n* create table `qr` in database, use schema from file `sql/qr.sql`\n* `$user-\u003eindentity` have to contain properties `id` and `username`\n\nConfiguration in config.neon.\n\n\n```yml\nextensions:\n    totpAuth: XRuff\\TotpAuth\\DI\\TotpAuthExtension\n\ntotpAuth:\n    issuer: NameOfMyApp  # mandatory\n    identityKey: login   # optional, Default is 'login' eg $user-\u003eidentity-\u003elogin\n    timeWindow: 1        # optional - time tolerance\n    codeSize: '300x300'  # optional - size ofgenerated QR code\n```\n\nPresenter:\n\n```php\n\nuse XRuff\\TotpAuth\\Auth;\nuse Nette\\Application\\UI;\n\nclass HomepagePresenter extends Nette\\Application\\UI\\Presenter\n{\n    /** @var Auth $auth */\n    public $auth;\n\n    public function __construct(Auth $auth)\n    {\n        $this-\u003eauth = $auth;\n    }\n\n    public function renderDefault() {\n        $this-\u003etemplate-\u003eqrCode = $this-\u003eauth-\u003egetQrBase64();\n    }\n\n    public function handleSaveUrl()\n    {\n        $this-\u003eauth-\u003esaveSecret();\n        $this-\u003eredirect('this');\n    }\n\n    public function handleResetUrl()\n    {\n        $this-\u003eauth-\u003eresetSecret();\n        $this-\u003eredirect('this');\n    }\n\n    protected function createComponentCodeForm()\n    {\n        $form = new UI\\Form;\n        $form-\u003eaddText('code', 'Code');\n        $form-\u003eaddSubmit('submit', 'Auth me');\n        $form-\u003eonSuccess[] = [$this, 'codeFormSucceeded'];\n        return $form;\n    }\n\n    public function codeFormSucceeded(UI\\Form $form, $values)\n    {\n        if ($this-\u003eauth-\u003everify($values-\u003ecode)) {\n            $this-\u003eflashMessage('Success!');\n        } else {\n            $this-\u003eflashMessage('Wrong code.');\n        }\n        $this-\u003eredirect('this');\n    }\n}\n```\n\ndefault.latte:\n\n```smarty\n    ...\n    {if $qrCode}\n        \u003cimg src=\"{$qrCode|nocheck}\" alt=\"\"\u003e\n        \u003cbr\u003e\n        \u003ca n:href=\"saveUrl!\" class=\"btn btn-success\"\u003eConfirm Code (have been added to Mobile Authenticator App)\u003c/a\u003e\n    {else}\n        {control codeForm}\n        \u003ca n:href=\"resetUrl!\" class=\"btn btn-success\"\u003eReset auth code\u003c/a\u003e\n    {/if}\n    ...\n```\n\n-----\n\nRepository [https://github.com/XRuff/TotpAuth](https://github.com/XRuff/TotpAuth).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxruff%2Ftotpauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxruff%2Ftotpauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxruff%2Ftotpauth/lists"}