New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

raditzfarhan/laravel-user-security

Add security pin, mnemonic key and 2fa authentication feature to users.
708 3
Install
composer require raditzfarhan/laravel-user-security
Latest Version:v1.0.0
Laravel:6 · 7 · 8
License:MIT
Last Updated:May 5, 2020
Links: GitHub  ·  Packagist
Maintainer: raditzfarhan

License styleci

Laravel User Security - RFAuthenticator

Add security pin, mnemonic key and 2fa authentication feature to users.

Installation

Via Composer

$ composer require raditzfarhan/laravel-user-security:^1.0

Configuration

The Laravel and Lumen configurations vary slightly, so here are the instructions for each of the frameworks.

Laravel

Edit the config/app.php file and add the following line to register the service provider:

'providers' => [
    ...
    RaditzFarhan\UserSecurity\UserSecurityServiceProvider::class,
    ...
],

Tip: If you're on Laravel version 5.5 or higher, you can skip this part of the setup in favour of the Auto-Discovery feature.

Lumen

Edit the bootstrap/app.php file and add the following line to register the service provider:

...
$app->register(RaditzFarhan\UserSecurity\UserSecurityServiceProvider::class);
...

You will also need to enable Facades in bootstrap/app.php:

..
$app->withFacades(true, [
    ...
    RaditzFarhan\UserSecurity\Facades\RFAuthenticator::class => 'RFAuthenticator'
]);
...

Open your user provider model class, for example App\User, and add RaditzFarhan\UserSecurity\Traits\UserSecurable trait:

<?php

namespace App;

...
use RaditzFarhan\UserSecurity\Traits\UserSecurable;

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    ...
    use UserSecurable;
    ...
}

Usage

Example usage as below snippet:

// to add/update security pin for eloquent user
$user->updateSecurityPin($security_pin);

// to add/update entropy for eloquent user
$user->updateEntropy($entropy);

// to add/update multiple authenticators
$user->updateMultipleAuthenticators(['security_pin' => $security_pin, 'mnemonic_entropy' => $entropy]);

To use mnemonic functions, examples as below:

// Success response

// using service container to generate mnemonic object
$mnemonic = app('RFAuthenticator')->mnemonic()->generate();

// using alias to generate mnemonic object
$mnemonic = \RFAuthenticator::mnemonic()->generate();

// Use mnemonic codes to find entropy
$mnemonic = \RFAuthenticator::mnemonic()->words($words);

// Generate Mnemonic using specified Entropy
$mnemonic = \RFAuthenticator::mnemonic()->entropy($entropy);

Change log

Please see the changelog for more information on what has changed recently.

Credits

License

MIT. Please see the license file for more information.

Related Packages

custom-d/user-security-recovery

A user security recovery

2,691 0
comes/simpleauthenticator

A PHP library for implementing Google Authenticator's two-factor authentication...

10,194 0
w3ns0n/lumen-permission

Permission handling for lumen 6.x and up

923 0
mingzaily/lumen-permission

Permission handling for lumen 6.x and up

85 2
adesin-fr/laravel-mail-2fa

Laravel 2FA package using email OTP codes with InertiaJS support

44 0

Version History

Version Released Laravel License
v1.0.0 ^6.0|^7.0|^8.0 MIT