{"id":18695684,"url":"https://github.com/sicaboy/laravel-mfa","last_synced_at":"2025-04-12T07:25:49.928Z","repository":{"id":57050298,"uuid":"255084674","full_name":"sicaboy/laravel-mfa","owner":"sicaboy","description":"Laravel 2FA / Multi-factor Authentication","archived":false,"fork":false,"pushed_at":"2023-07-19T19:53:29.000Z","size":143,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T02:42:41.362Z","etag":null,"topics":["2fa","factor-authentication","laravel","mfa","middleware"],"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/sicaboy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-12T13:08:33.000Z","updated_at":"2025-03-19T16:53:41.000Z","dependencies_parsed_at":"2023-02-09T11:16:35.935Z","dependency_job_id":null,"html_url":"https://github.com/sicaboy/laravel-mfa","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sicaboy%2Flaravel-mfa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sicaboy%2Flaravel-mfa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sicaboy%2Flaravel-mfa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sicaboy%2Flaravel-mfa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sicaboy","download_url":"https://codeload.github.com/sicaboy/laravel-mfa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248532426,"owners_count":21119909,"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","factor-authentication","laravel","mfa","middleware"],"created_at":"2024-11-07T11:15:48.709Z","updated_at":"2025-04-12T07:25:49.907Z","avatar_url":"https://github.com/sicaboy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Multi-factor Authentication (MFA) / Two-factor Authentication (2FA)\n\n[![Latest Stable Version](https://poser.pugx.org/sicaboy/laravel-mfa/v/stable.svg)](https://packagist.org/packages/sicaboy/laravel-mfa)\n[![License](https://poser.pugx.org/sicaboy/laravel-mfa/license.svg)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/sicaboy/laravel-mfa.svg?style=flat-square)](https://packagist.org/packages/sicaboy/laravel-mfa)\n\n## Introduction\n\nThis package was a part of [sicaboy/laravel-security](https://github.com/sicaboy/laravel-security). Later moved to this separated repository.\n\nThis package provides a Middleware to protect pages with MFA in your Laravel projects.\n\n\n## Installation\n\nRequirements:\n- [PHP](https://php.net) 5.5+, 7.*, 8.0+\n- [Composer](https://getcomposer.org)\n\nTo get the latest version of Laravel MFA, simply run:\n\n```\ncomposer require sicaboy/laravel-mfa\n```\n\nThen do vendor publish:\n\n```\nphp artisan vendor:publish --provider=\"Sicaboy\\LaravelMFA\\LaravelMFAServiceProvider\"\n```\n\nAfter publishing, you can modify templates and config in:\n\n```\napp/config/laravel-mfa.php\nresources/views/vendor/laravel-mfa/\n```\n\nIf you're on Laravel \u003c 5.5, you'll need to register the service provider. Open up `config/app.php` and add the following to the `providers` array:\n\n```php\nSiaboy\\LaravelMFA\\LaravelMFAServiceProvider::class,\n```\n\n# Usage\n\n### General Usage\n\nAttach the middleware to your routes to protect your pages.\n\n```php\nRoute::middleware(['mfa'])-\u003egroup(function () {\n    ...\n});\n```\n\n### If Using Different Auth Objects\nIf you use different `Auth` objects, for example user auth and admin auth, you can apply following to enable MFA for admin pages. \n\n- Attach the middleware to your routes.\n\n```php\nRoute::middleware(['mfa:admin'])-\u003egroup(function () {\n    ...\n});\n```\n\n- Add a group in your config file `config/laravel-mfa.php`\n\n```php\nreturn [\n    'default' =\u003e [\n        ...\n    ],\n    'group' \n        'admin' =\u003e [ // Example, when using middleware 'mfa:admin'. Attributes not mentioned will be inherit from `default` above\n            'login_route' =\u003e 'admin.login',\n            'auth_user_closure' =\u003e function() {\n                return \\Encore\\Admin\\Facades\\Admin::user();\n            },\n        ],\n        'other_name' =\u003e [ // Middleware 'mfa:other_name'\n            ...\n        ]\n    ],\n```\n\n## Queue\n\nIf your application has a `artisan queue:work` daemon running, you can send auth code in a queue by changing the config.\n\n```php\nreturn [\n    'default' =\u003e [\n        ...\n        'email' =\u003e [\n            'queue' =\u003e true,\n        ...\n        ]\n    ]\n]\n```\n\n\n## TODO\n\n- Switch on MFA on specific users (DB field-based)\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsicaboy%2Flaravel-mfa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsicaboy%2Flaravel-mfa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsicaboy%2Flaravel-mfa/lists"}