PHPackages                             elshaden/apiato-otpkey - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. elshaden/apiato-otpkey

ActiveApiato-container[Framework](/categories/framework)

elshaden/apiato-otpkey
======================

Implementation of 2 factor Authentication using TOTP In Apiato Projects .

1.0.0(3y ago)6352MITPHP

Since Sep 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Elshaden/apiato-otpkey)[ Packagist](https://packagist.org/packages/elshaden/apiato-otpkey)[ RSS](/packages/elshaden-apiato-otpkey/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (22)Used By (0)

[Apiato](https://github.com/apiato/apiato) 2FA Container
========================================================

[](#apiato-2fa-container)

### Multi-Factor Authentication MFA , 2FA.

[](#multi-factor-authentication-mfa---2fa)

#### This Container is used to manage the 2 Factor Authentication using any app like Google Authenticator

[](#this-container-is-used-to-manage-the-2-factor-authentication-using-any-app-like-google-authenticator)

#### Note: This container is not fully tested, use with caution.

[](#note-this-container-is-not-fully-tested-use-with-caution)

### Installation

[](#installation)

Only Works in Existing Apiato Application
Read more about the Apiato container installer in the [docs](http://apiato.io/docs/miscellaneous/container-installer)!

#### Steps

[](#steps)

> composer require elshaden/apiato-otpkey

> Add the ***use HasOtpKeyTrait*** in the User Model

> Migrate the table 'otp\_keys'

> and you are ready to go

> Check Config File in Configs Dir for any changes

### Usage

[](#usage)

#### To find if user has MFA Key

[](#to-find-if-user-has-mfa-key)

```
$user-> HasOtp();

```

This will return the full record of the Otp Key.

```
object   // OtpKey
id          // Hashed OtpKey Id
user_id
code      // Base64 OtpKey Code
qr_code    // QR Code Image
active     // Active or not
created_at
updated_at
readable_created_at
readable_updated_at

```

#### To Create New MFA key

[](#to-create-new-mfa-key)

```
$user-> CreateOtpKey();

```

This will return : The Otp\_key Record created with otp Key ( basse 64 TOTP key) QR code inform of Base 64 Image and the user Id

#### Update the Key

[](#update-the-key)

```
$user->UpdateKey();

```

This will regnertae the Key and updates the record

#### To generate a QR code for a given code

[](#to-generate-a-qr-code-for-a-given-code)

```
$user->GetQrCode($code) ;

```

#### To Verfiy a given Token is valid ( the six numbers in the authenticator)

[](#to-verfiy-a-given-token-is-valid--the-six-numbers-in-the-authenticator)

```
$user->ValidateKey($Code);       // The code must be the six digits in the Authenticator

```

#### Generate Code

[](#generate-code)

```
$user->GenerateCode();

```

This will generate a 6 Digits Code based on the user token, at any given time The code should match any authenticator App's such as Google Authenticator

API Endpoints
=============

[](#api-endpoints)

EndpointMethodParameteresUsageResponse**/otpkeys**POSTuser\_idCreates New User Token`string "id",   int "user_id",  string "code",   image "qr_code" `**/validate-otpkeys**POSTid , pin , slotsValidates 6 digits pin`bool "result" `**/validate-usercode**POSTpinValidates pin By User Bearer Token`bool "result" `**/generate-otpkey**GETGenerates 6 Digits pin From Bearer Token`int "code"   `In Addition to Find, delete and Update OtpToken for any user.

Note when validating the Otp in validate-otpkeys slots means validate the key for past of 30 seconds each.

For example 10 Slots means 10 \* 30 seconds = 300 seconds / 60 = 5 minutes. So the Otp is valid for the pas 5 minutes.

For 5 Minutes Token, slots = 5 \* 60 = 300

For one day Token, slots = 24 \* 60 \* 60 = 86400

the longer the period the more time it takes to check the validity, so please try to be conservative.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~116 days

Total

20

Last Release

1228d ago

Major Versions

0.1.12 → 1.0.02023-01-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2b7d966d6b72d533ef1afdb7b498c9bf306fc480fb6563bcd8cdf47c21b1a27?d=identicon)[Elshaden](/maintainers/Elshaden)

---

Top Contributors

[![Elshaden](https://avatars.githubusercontent.com/u/33955172?v=4)](https://github.com/Elshaden "Elshaden (27 commits)")

---

Tags

apiframework2faMFAapiatoAutenticator

### Embed Badge

![Health badge](/badges/elshaden-apiato-otpkey/health.svg)

```
[![Health](https://phpackages.com/badges/elshaden-apiato-otpkey/health.svg)](https://phpackages.com/packages/elshaden-apiato-otpkey)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[apiato/apiato

A flawless framework for building scalable and testable API-Centric Apps with PHP and Laravel.

3.1k31.8k](/packages/apiato-apiato)[lanin/laravel-api-debugger

Easily debug your JSON API.

2311.8M](/packages/lanin-laravel-api-debugger)[gotzmann/comet

Modern PHP framework for building blazing fast REST APIs and microservices

68816.2k1](/packages/gotzmann-comet)[psx/psx

PHP REST API Framework

17112.6k3](/packages/psx-psx)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
