You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TAATP/src/Required/PersistenceInterface.php

61 lines
2.4 KiB

<?php declare(strict_types=1);
/**
*
*/
namespace BradyMcD\TAATP\Required;
/**
* Implements the required persistence functions for a TOTP system.
* It is MANDATORY that this be implemented by the user of this module to make everything talk to their database.
*/
interface PersistenceInterface
{
/**
* Takes user indexing data and returns a string suitable for tagging and human readable info strings.
* @param mixed $index Whatever data needed to index info your database and identify a particular user
* @return string
*/
public function userString(mixed $index): string;
/**
* Stores the otpauth URI for the user associated with the given indexing data.
* @param mixed $index Whatever data needed to index into your database and identify a particular user
* @param string $secret The secret datastring used to seed the TOTP rolling hash
* @return void
*/
public function storeSecret(mixed $index, string $secret);
/**
* Removes the secret key for the user associated with the given indexing data.
* @param mixed $index Whatever data needed to index into your database and identify a particular user
*/
public function stripSecret(mixed $index);
/**
* As the name suggests One-Time-Passwords should only be usable one time!
* We store the timestamp of the last valid challenge to enforce this.
* @param mixed $index Whatever data needed to index into your database and identify a particular user
* @param int $timestamp A UNIX timestamp representing the last successful challenge time.
* Only codes generated at a time greater than the indicated time will be deemed valid.
* @return bool
*/
public function storeLastTime(mixed $index, int $timestamp);
/**
* Gets and returns the otpauth URI for the user associated with the given user_id.
* Return null if the user isn't enrolled for TOTP 2-factor authentication.
* @param mixed $index Whatever data needed to index into your database and identify a particular user
* @return null|string
*/
public function getSecret(mixed $index): null|string;
/**
* Gets and returns the last successful challenge timestamp to enforce the One-Time aspect of a TOTP.
* @param mixed $index Whatever data needed to index into your database and identify a particular user
* @return int
*/
public function getLastTime(mixed $index): int;
}
?>