定制 geoffry304/yii2-authy 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geoffry304/yii2-authy

Composer 安装命令:

composer require geoffry304/yii2-authy

包简介

Yii2 authy 2FA

README 文档

README

Latest Version Software License Total Downloads

Extension for using 2FA from Authy with Yii2 and amnah/yii2-user

Installation

The preferred way to install yii2-authy is through Composer. Either add the following to the require section of your composer.json file:

"geoffry304/yii2-authy": "*"

Or run:

$ php composer.phar require geoffry304/yii2-authy "*"

You can manually install yii2-authy by downloading the source in ZIP-format.

Run the migration file php yii migrate --migrationPath=@vendor/geoffry304/yii2-authy/migrations

Update the config file

// app/config/web.php
return [
    'modules' => [
        'authy' => [
            'class' => 'geoffry304\authy\Module',
            'api_key' => 'here your api key from authy',
            'send_mail_from => 'demo@example.com'
        ],
        'user' => [
            'class' => 'amnah\yii2\user\Module',
            'modelClasses' => [
                'LoginForm' => 'geoffry304\authy\forms\LoginForm'
            ]
        ],
    ],
];

Using Authy

You need to add this piece of code before you try performLogin

$module2FA = Yii::$app->getModule('authy');
if ($module2FA) {
    Yii::$app->session->set('credentials', ['login' => $model->email, 'pwd' => $model->password, 'remember' => $rememberMe]);
    $returnUrl = $module2FA->validateLogin($model->getUser());
    return $returnUrl;  
}

Options

Module Has the following options to modify it's behaviour:

  • api_key: The key you get from authy website to make connection with it.
  • api_url: If you want to use an other url standard to https://api.authy.com.
  • default_expirytime: The expire time the user will need to insert a new token standard to 30 days.
  • send_mail: Send mail when new device is added, standard to true.
  • send_mail_from: Send mail from required when send_mail is on.
  • logo: Path tho logo used in confirmation and registration form and also in sending mail.

If you need extra security, you can check on every action and controller if the current session still exist in db.

Update the config file

// app/config/web.php
return [
    'bootstrap' => ['GlobalCheck'],
    'components' => [
        'GlobalCheck'=> [
            'class'=>'geoffry304\authy\components\GlobalCheck'
         ],
     ],
];

统计信息

  • 总下载量: 77
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-01-03