Skip to content
forked from hiqdev/yii2-mfa

Yii2 module providing multi-factor authentication

License

Notifications You must be signed in to change notification settings

itexia/yii2-mfa

 
 

Repository files navigation

Yii2 MFA

Multi-factor authentication for Yii2 projects

Latest Stable Version Total Downloads Build Status Scrutinizer Code Coverage Scrutinizer Code Quality Dependency Status

This package provides:

  • TOTP - Time-based One-time Password Algorithm used for two factor authentication
  • checking for user allowed IPs
  • generation and checking recovery codes (PLANNED)

Uses:

Can be plugged into any exising Yii2 project. See how it is used in hiqdev/hiam.

Installation

The preferred way to install this yii2-extension is through composer.

Either run

php composer.phar require "hiqdev/yii2-mfa"

or add

"hiqdev/yii2-mfa": "*"

to the require section of your composer.json.

Configuration

This extension provides pluggable configuration to be used with composer-config-plugin.

Also you can use it usual way by copy-pasting config. See src/config/web.php for configuration example.

Available configuration parameters:

  • organization.name

For more details please see src/config/params.php.

Usage

This plugin provides behavior and configuration attaches it to user component on beforeLogin event. And then the behavior validates IPs and TOTP on every login.

To use this plugin you have to instantiate your \Yii->app->user->identity class from hiqdev\yii2\mfa\base\MfaIdentityInterface and implement all of the methods, which will return or set MFA properties. For example:

use hiqdev\yii2\mfa\base\MfaIdentityInterface;

class Identity implements MfaIdentityInterface
{
    ...

    /**
     * @inheritDoc
     */
    public function getUsername(): string
    {
        return $this->username;
    }

    /**
     * @inheritDoc
     */
    public function getTotpSecret(): string
    {
        return $this->totp_secret ?? '';
    }

    ...

IPs and TOTP functions are independent and you can provide just one of properties to have only corresponding functionality.

License

This project is released under the terms of the BSD-3-Clause license. Read more here.

Copyright © 2016-2018, HiQDev (http://hiqdev.com/)

About

Yii2 module providing multi-factor authentication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%