2017 © Pedro Peláez
 

yii2-extension yii2-twofa

Provides TOTP and QR codes for use with an authenticator like the one from Google or Authy

image

promocat/yii2-twofa

Provides TOTP and QR codes for use with an authenticator like the one from Google or Authy

  • Monday, May 28, 2018
  • by C4RoCKeT
  • Repository
  • 2 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 80 % Grown

The README.md

Extension for Yii2 providing Two Factor Authentication

Provides TOTP and QR codes for use with an authenticator like the one from Google or Authy, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist promocat/yii2-twofa "*"

or add, (*4)

"promocat/yii2-twofa": "*"

to the require section of your composer.json file., (*5)

Setup

Update the user component in your config file to use the class, (*6)

promocat\twofa\User::class

It should sorta look like this, (*7)

'components' => [
    'user' => [
        'class' => promocat\twofa\User::class,
        'identityClass' => 'common\models\User',
        'enableAutoLogin' => true,
        'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
    ]
]

Also add the "twoFa" component:, (*8)

'twoFa' => ['class' => promocat\twofa\TwoFa::class]

Next, add the TwoFaBehavior to your User model, (*9)

public function behaviors() {
    return [
        'two_fa' => ['class' => TwoFaBehavior::class]
    ];
}

Usage

Congratulations, you can now, for example, call, (*10)

Yii::$app->twofa->generateSecret()

or, (*11)

Yii::$app->twofa->checkCode($secret, $code);

Use, (*12)

promocat\models\TwoFaForm

for the 2FA activation and verification forms. Or at least let is be an example., (*13)

QR Code Widget

<?= TwoFaQr::widget([
    'accountName' => $model->user->username,
    'secret' => $model->secret,
    'issuer' => Yii::$app->params['twoFaIssuer'],
    'size' => 300
]); ?>

How to functionally implement:

See "example.php" to get started., (*14)

The Versions

28/05 2018

dev-master

9999999-dev https://github.com/promocat/yii2-twofa

Provides TOTP and QR codes for use with an authenticator like the one from Google or Authy

  Sources   Download

MIT

The Requires

 

by Brandon Tilstra

yii2 otp 2fa qr google authenticator totp two factor authentication authy

16/05 2018

0.1.0

0.1.0.0 https://github.com/promocat/yii2-twofa

Provides TOTP and QR codes for use with an authenticator like the one from Google or Authy

  Sources   Download

MIT

The Requires

 

by Brandon Tilstra

yii2 otp 2fa qr google authenticator totp two factor authentication authy