2026-01-26 21:08:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-01-27 00:58:42 +00:00
|
|
|
namespace Core\Mod\Tenant\Contracts;
|
2026-01-26 21:08:59 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Contract for two-factor authentication providers.
|
|
|
|
|
*
|
|
|
|
|
* Handles TOTP (Time-based One-Time Password) generation and verification
|
|
|
|
|
* for user accounts. Typically implemented using libraries like Google Authenticator.
|
|
|
|
|
*/
|
|
|
|
|
interface TwoFactorAuthenticationProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new secret key for TOTP.
|
|
|
|
|
*/
|
|
|
|
|
public function generateSecretKey(): string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate QR code URL for authenticator app setup.
|
|
|
|
|
*
|
|
|
|
|
* @param string $name Application/account name
|
|
|
|
|
* @param string $email User email
|
|
|
|
|
* @param string $secret TOTP secret key
|
|
|
|
|
*/
|
|
|
|
|
public function qrCodeUrl(string $name, string $email, string $secret): string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify a TOTP code against the secret.
|
|
|
|
|
*
|
|
|
|
|
* @param string $secret TOTP secret key
|
|
|
|
|
* @param string $code User-provided 6-digit code
|
|
|
|
|
*/
|
|
|
|
|
public function verify(string $secret, string $code): bool;
|
|
|
|
|
}
|