Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
tool_mfa\local\secret_manager Class Reference

Public Member Functions

 __construct (string $factor)
 Initialises a secret manager instance.
 
 cleanup_temp_secrets ($userid=null)
 Deletes any user secrets hanging around in the database.
 
 create_secret (int $expires, bool $session, string $secret=null)
 This function creates or takes a secret, and stores it in the database or session.
 
 revoke_secret (string $secret, $userid=null)
 Revokes the provided secret code for the user.
 
 validate_secret (string $secret, bool $keep=false)
 Validates whether the provided secret is currently valid.
 

Public Attributes

string const NONVALID = 'nonvalid'
 
string const REVOKED = 'revoked'
 
string const VALID = 'valid'
 

Constructor & Destructor Documentation

◆ __construct()

tool_mfa\local\secret_manager::__construct ( string $factor)

Initialises a secret manager instance.

Parameters
string$factor

Member Function Documentation

◆ cleanup_temp_secrets()

tool_mfa\local\secret_manager::cleanup_temp_secrets ( $userid = null)

Deletes any user secrets hanging around in the database.

Parameters
int$useridthe userid to cleanup temp secrets for.
Return values
void

◆ create_secret()

tool_mfa\local\secret_manager::create_secret ( int $expires,
bool $session,
string $secret = null )

This function creates or takes a secret, and stores it in the database or session.

Parameters
int$expiresthe length of time the secret is valid. e.g. 1 min = 60
bool$sessionwhether this secret should be linked to the session.
string$secretan optional provided secret
Return values
stringthe secret code, or 0 if no new code created.

◆ revoke_secret()

tool_mfa\local\secret_manager::revoke_secret ( string $secret,
$userid = null )

Revokes the provided secret code for the user.

Parameters
string$secretthe secret to revoke.
int$useridthe userid to revoke the secret for.
Return values
void

◆ validate_secret()

tool_mfa\local\secret_manager::validate_secret ( string $secret,
bool $keep = false )

Validates whether the provided secret is currently valid.

Parameters
string$secretthe secret to check
bool$keepshould the secret be kept for reuse until expiry?
Return values
stringa secret manager state constant

The documentation for this class was generated from the following file: