fragotesac/zf1-2fa
最新稳定版本:v1.5
Composer 安装命令:
composer require fragotesac/zf1-2fa
包简介
Zend Framework 1 2FA component
关键字:
README 文档
README
This PHP library provides two-factor authentication (2FA) functionality for Zend Framework 1 applications. It allows for secure user login by requiring an additional step of verification, enhancing application security.
How to Use
Backend Configuration
-
Create an Action:
Implement an action in your backend where 2FA will be handled. -
Instantiate the 2FA Service:
$this->tfa = new \Zend\TwoFactorAuth();
- Set Mail Configuration:
$this->tfa->setMailConfig([ 'transport' => [], // Mail transport settings 'subject' => '', // Email subject for 2FA codes 'from' => ['email' => '', 'name' => ''], // Sender details 'template' => [] // Email template configuration ]);
- Initialize the 2FA Service: Call the init method with a callback function to validate the user:
$this->tfa->init([$this, 'checkUser']);
- Implement the checkUser Method:
This method should handle user validation and error management using
Zend\Util\ResponseUtil.
Client-Side Setup
-
Copy the Client Folder:
Copy the2fa-clientfolder located insidesrcand place it in yourpublic/js/directory. -
Initialize the 2FA Client:
Use the following JavaScript code to initialize the 2FA client:
zfTwoFactorAuth.init(apiUrl, data, 'glass-theme', (loginFormData, url) => { // Handle the login callback here });
apiUrl: The API endpoint previously created for 2FA.data: The login form fields converted into an object, e.g., {username: 'joe', password: 123456}.glass-theme: The style theme for the 2FA modal. Available themes are:glass-themecds-themeCallback Function: Handles the login URL and sanitized parameters.
Requirements
- Zend Framework 1
- PHP 8.0 or higher
- Composer for dependency management
Installation
composer require fragotesac/zf1-2fa
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-01-15