Search by

narekmarkosyan / laravel-admin-telegram-two-factor

narekmarkosyan

Add Telegram based two factor authentication to laravel-admin

Package info

github.com/narekmarkosyan/laravel-admin-telegram-two-factor

pkg:composer/narekmarkosyan/laravel-admin-telegram-two-factor

Statistics

Installs: 234

Dependents: 0

Suggesters: 0

Stars: 0

v0.0.7 2026-09-24 14:14 UTC

This package is auto-updated.

Last update: 2026-10-11 12:27:39 UTC


README

Inspired from https://github.com/shanerutter/laravel-admin-email-two-factor

Adds two-factor authentication to admin login, admin will be sent a message in Telegram with a 6-digit code to complete sign in.

Notes

A new "telegram_id" field is added to the database as laravel-admin does not have this by default. Once installed and migrations completed, you will need to set each user's telegram ID via the database. No way of doing it via UI has been implemented at this time.

Installation

Requires PHP 8.3 or newer and Laravel 11, 12, or 13. The package uses narekmarkosyan/laravel-admin v1.9.2 or newer, which retains the Encore\Admin Composer name and namespace. Add the fork as a VCS repository in the consuming application's root composer.json before installing this package. Composer does not inherit VCS repositories from dependencies:

composer config repositories.narek-laravel-admin vcs https://github.com/narekmarkosyan/laravel-admin
composer require narekmarkosyan/laravel-admin-telegram-two-factor

Laravel 11 is past its security support window and currently has advisories that may cause Composer to block installation. The Laravel 11 CI job disables advisory blocking only to verify API compatibility. Use Laravel 12 or 13 for deployments.

Migration

Add telegram_id field to admin users table.

php artisan migrate

Configuration

In the extensions section of the config/admin.php file, add configurations

'extensions' => [
    'auth-telegram-two-factor' => [
        'enable' => (bool)env('ADMIN_AUTH_TELEGRAM_TWO_FACTOR', true),
        'botKey' => env('ADMIN_AUTH_TELEGRAM_TWO_FACTOR_BOT_KEY'),
        'pinLength' => (int)env('ADMIN_AUTH_TELEGRAM_TWO_FACTOR_PIN_LENGTH', 6),
        'rememberDays' => (int)env('ADMIN_AUTH_TELEGRAM_TWO_FACTOR_REMEMBER_DAYS', 1),
    ]
]

In the .env file, add configurations

ADMIN_AUTH_TELEGRAM_TWO_FACTOR=true
ADMIN_AUTH_TELEGRAM_TWO_FACTOR_BOT_KEY=123456789:AABBB_ZXCVBNMdfghjXCVvb_AA
ADMIN_AUTH_TELEGRAM_TWO_FACTOR_PIN_LENGTH=6
ADMIN_AUTH_TELEGRAM_TWO_FACTOR_REMEMBER_DAYS=1

License

Licensed under The MIT License (MIT).