{"id":20345674,"url":"https://github.com/teh9/laravel-tg-2fa","last_synced_at":"2025-08-22T05:35:13.590Z","repository":{"id":62841202,"uuid":"562984698","full_name":"teh9/laravel-tg-2fa","owner":"teh9","description":"A simple implementation of a two-factor authentication via Telegram for Laravel","archived":false,"fork":false,"pushed_at":"2023-05-08T19:16:21.000Z","size":36,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T05:41:59.776Z","etag":null,"topics":["2fa","auth","authentication","laravel","login","php","security","telegram","two-factor"],"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/teh9.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-07T17:04:49.000Z","updated_at":"2025-03-11T07:04:55.000Z","dependencies_parsed_at":"2025-04-12T00:41:24.621Z","dependency_job_id":"83c8f924-2f95-4232-a1a5-fd8dd6d9586f","html_url":"https://github.com/teh9/laravel-tg-2fa","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/teh9/laravel-tg-2fa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teh9%2Flaravel-tg-2fa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teh9%2Flaravel-tg-2fa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teh9%2Flaravel-tg-2fa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teh9%2Flaravel-tg-2fa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teh9","download_url":"https://codeload.github.com/teh9/laravel-tg-2fa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teh9%2Flaravel-tg-2fa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271591293,"owners_count":24786395,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["2fa","auth","authentication","laravel","login","php","security","telegram","two-factor"],"created_at":"2024-11-14T22:09:22.109Z","updated_at":"2025-08-22T05:35:13.564Z","avatar_url":"https://github.com/teh9.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel two-factor authentication via Telegram\n\nA simple two-factor implementation using Telegram for Laravel.\n\n![Packagist Downloads](https://img.shields.io/packagist/dt/teh9/laravel2fa)\n![Packagist Version](https://img.shields.io/packagist/v/teh9/laravel2fa)\n![Packagist License](https://img.shields.io/github/license/teh9/laravel-tg-2fa)\n\n## Installation\n\nYou can install the package via composer:\n```\ncomposer require teh9/laravel2fa\n```\n\nPublish the package config, migrations \u0026 localizations files:\n\n```\nphp artisan vendor:publish --provider=\"Teh9\\Laravel2fa\\TelegramTwoFactorServiceProvider\"\n```\n\n## Usage\n\n### Set up\n\nIn your project folder `config/laravel2fa.php`, provide bot api key it can be received by official telegram bot \u003ca href=\"https://telegram.me/BotFather\"\u003e@BotFather\u003c/a\u003e \n\n```php \n'api_key' =\u003e 'YOUR_BOT_API_KEY'\n```\n\n### Migrations\n\nAfter publishing, you will have migration, execute:\n\n``` \nphp artisan migrate\n```\n\nWill be added 2 columns for **users** table, if you want change table you can do it in migration file:\n`database/migrations/add_two_factor_columns_to_model_table.php`\n```\nchat_id - big integer|nullable|deafult-null\nsecret  - string     |nullable|default-null\n```\n\n### Languages\n\n2 languages are available in files **/resources/lang/`[lang]`/2fa.php**:\n- en;\n- ru;\n\nYou can add any else but watch on existed implementations on how to make it correctly\n\n### Prepare Users Model:\n\n```php \nclass User extends Model implements TelegramTwoFactor\n{\n    use HasAuth;\n}\n```\n\n### Save code in database and send notification with code in telegram\n\n```php \n$user = User::first();\n// Might be passed 2 params\n// 1-st preffered length of code by default 6\n// 2-nd is language by default en\n$user-\u003esendCode(4, 'ru'); // return boolean\n```\n\n### Validate code\n\n```php \n// The received code from the telegram must be passed to the method, which is described below\n$code = 'CODE_FROM_TELEGRAM'; \n$user = User::first();\n$user-\u003evalidateCode($code); // return boolean\n```\n\n## License\n\nThe MIT License (MIT). Please see \u003ca href=\"https://github.com/teh9/laravel-tg-2fa/blob/master/LICENSE\"\u003eLicense File\u003c/a\u003e for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteh9%2Flaravel-tg-2fa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteh9%2Flaravel-tg-2fa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteh9%2Flaravel-tg-2fa/lists"}