{"id":37005285,"url":"https://github.com/thecodework/two-factor-authentication","last_synced_at":"2026-01-14T00:39:58.941Z","repository":{"id":18800346,"uuid":"85341644","full_name":"thecodework/two-factor-authentication","owner":"thecodework","description":"Two Factor Authentication for Laravel","archived":false,"fork":false,"pushed_at":"2023-04-19T19:27:47.000Z","size":416,"stargazers_count":21,"open_issues_count":8,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-11-13T08:16:18.573Z","etag":null,"topics":["laravel","laravel-5-package","two-factor-authentication","two-step-authentication"],"latest_commit_sha":null,"homepage":"http://imrealashu.in/code/laravel/two-factor-authentication-in-laravel/","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/thecodework.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-03-17T18:10:13.000Z","updated_at":"2024-04-29T18:31:12.000Z","dependencies_parsed_at":"2023-02-17T10:01:24.555Z","dependency_job_id":null,"html_url":"https://github.com/thecodework/two-factor-authentication","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/thecodework/two-factor-authentication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodework%2Ftwo-factor-authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodework%2Ftwo-factor-authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodework%2Ftwo-factor-authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodework%2Ftwo-factor-authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodework","download_url":"https://codeload.github.com/thecodework/two-factor-authentication/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodework%2Ftwo-factor-authentication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["laravel","laravel-5-package","two-factor-authentication","two-step-authentication"],"created_at":"2026-01-14T00:39:58.812Z","updated_at":"2026-01-14T00:39:58.915Z","avatar_url":"https://github.com/thecodework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/thecodework/two-factor-authentication.svg?branch=master)](https://travis-ci.org/thecodework/two-factor-authentication)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodework/two-factor-authentication/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thecodework/two-factor-authentication/?branch=master)\n[![StyleCI](https://styleci.io/repos/85341644/shield?branch=master)](https://styleci.io/repos/85341644)\n[![License](https://poser.pugx.org/thecodework/two-factor-authentication/license)](https://packagist.org/packages/thecodework/two-factor-authentication)\n\n# Laravel Two Factor Authentication (2FA)\n\n![Two](http://imrealashu.in/wp-content/uploads/2017/04/Screen-Shot-2017-04-10-at-00.19.05.png)\n\nTwo Factor Authentication or 2-Step Verification provides stronger security for your Account by requiring a second step of verification when you sign in. In addition to your password, you’ll also need a code generated by the Google Authenticator app on your phone. This package implements TOTP defined in [RFC 6238](https://tools.ietf.org/html/rfc6238)\n\n## Requirements\n\n- PHP \u003e= 7.1\n- Laravel \u003e= 5.3\n- Google Authenticator [Android](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\u0026hl=en) - [iOS](https://itunes.apple.com/in/app/google-authenticator/id388497605?mt=8) (Recommended) or [Authy](https://www.authy.com/) mobile app\n\n## Installation\n\n**1. Composer Install**\n\n```bash\n$ composer require thecodework/two-factor-authentication\n```\n\n_Note_ - If your're using Laravel 5.5 or newer version then auto-discovery-pacakge would automatically update the providers and you could skip to **Step 3**\n\n**2. Add Service Provider**\n\nAfter requiring the package add `TwoFactorAuthenticationServiceProvider::class` into providors array in `app.php` confi file\n\n```php\n[\n 'providers' =\u003e [\n    //...\n    Thecodework\\TwoFactorAuthentication\\TwoFactorAuthenticationServiceProvider::class\n  ]\n]\n```\n\n**3. Publish the ConfigFile**\n\nPublish config file\n\n```\n$ php artisan vendor:publish --provider=\"Thecodework\\TwoFactorAuthentication\\TwoFactorAuthenticationServiceProvider\" --tag=config\n```\n\nOnce the config file is published you can navigate to config directory of your application and look for `2fa-config.php` file and change configuration as you want.\n\n**4. Run Migrations**\n\nNow run the migration\n\n```bash\n$ php artisan migrate\n```\n\nIt will use the default User model and adds two columns `is_2fa_enabled` and `secret_key`.\n\n**5. Add `AuthenticatesUserWith2FA` trait in the LoginController**\n\nNow the config file is placed. The last thing to do is addding `AuthenticatesUsersWith2FA` trait in the `Http/Controllers/Auth/LoginController.php` file which helps to stop user at verify-2fa page to enter TOTP token after each login.\n\nThe final snippet will look like this.\n\n```php\nuse AuthenticatesUsers, AuthenticatesUsersWith2FA {\n    AuthenticatesUsersWith2FA::authenticated insteadof AuthenticatesUsers;\n}\n```\n\nNote: Don't forget to include use statement `use Thecodework\\TwoFactorAuthentication\\AuthenticatesUsersWith2FA` in the header.\n\n**6. Setup 2FA for user**\n\n**• Enable 2FA**\n\nNow login to the application and visit `/setup-2fa/` route, which will show a barcode which can be scanned either using Google Authenticator or Authy mobile application as described above.\nScan that code and click **Enable Two Factor Authentication**.\n\n**• Disable 2FA**\n\nTo disable Two Factor, visit `/setup-2fa` route, which will now show a **Disable Two Factor Authentication** button. Click to disable 2FA for your account.\n\n**7. Testing 2FA**\n\nNow to test 2FA, perform logout and log back in again, it will ask you to enter Token which can be obtain from the authenticator mobile application. Enter the token and you're logged in.\n\n### Additionally\n\nIf you want to publish views, and migration as well along with config file then run\n\n```\n$ php artisan vendor:publish --provider=\"Thecodework\\TwoFactorAuthentication\\TwoFactorAuthenticationServiceProvider\"\n```\n\n## Contribution\n\nFeel free to create issues, submit PRs and talk about features and enhancement through proposing issue. If you find any security consideration, instead of creating an issue send an email to [imrealashu@gmail.com](mailto:imrealashu@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodework%2Ftwo-factor-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodework%2Ftwo-factor-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodework%2Ftwo-factor-authentication/lists"}