phant/otp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

phant/otp

最新稳定版本:1.1

Composer 安装命令:

composer require phant/otp

包简介

Manage OTP easily

README 文档

README

Presentation

The OTP service is designed to manage OTPs (One Time Passwords) that can be used for authentication, confirmation or any other validation requirement for a user.

Process :

  1. The service generate an OTP and send it to the user,
  2. The user receives the OTP,
  3. The application retrieves the OTP from the user,
  4. The application verifies the OTP with the service.

The OTP is sent to the user by your own OtpSender service (e-mail, SMS, etc.).

Technologies used

  • PHP 8.2
  • Composer for dependencies management (PHP)

Installation

composer install

Usage

Config

use Phant\DataStructure\Key\Ssl as SslKey;
use Phant\Otp\Service\Request as Service;
use App\OtpRepository;
use App\OtpSender;

// Config

$otpRepository = new OtpRepository();
$otpSender = new OtpSender();
$sslKey = new SslKey($privateKey, $publicKey);


// Build service

$service = new Service(
	$otpRepository,
	$otpSender,
	$sslKey
);

Request OTP

// OTP context transmitted to sender
$payload = [
	'email' => 'willy@wonka.com',
];

$requestToken = $service->generate(
	$payload
);

Verify OTP

use Phant\Error\NotCompliant;

// Request token obtained previously
$requestToken = '...';

// Obtain Otp from user
$otp = '123456';

try {
	$payload = $service->verify(
		$requestToken,
		$otp
	);
} catch (NotCompliant $e) {
	$numberOfAttemptsRemaining = $otpService->getNumberOfRemainingAttempts(
		$requestToken
	);
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-28