Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe Totp

Fonctions membres publiques

 __construct ($timeStep=30, $passCodeLength=6, $secretLength=10, $base32=null)
 
 getPeriod ($time=null)
 
 checkCode ($secret, $code)
 
 getCode ($secret, $time=null)
 
 getUrl ($user, $hostname, $secret)
 
 generateSecret ()
 

Fonctions membres protégées

 hashToInt ($bytes, $start)
 

Attributs privés

 $_passCodeLength = 6
 
 $_pinModulo
 
 $_secretLength = 20
 
 $_timeStep = 30
 
 $_base32 = null
 

Description détaillée

This class provides an RFC6238-compliant Time-based One Time Passwords, compatible with Google Authenticator (with PassCodeLength = 6 and TimePeriod = 30).

Depuis
4.0.0

Documentation des constructeurs et destructeur

◆ __construct()

__construct (   $timeStep = 30,
  $passCodeLength = 6,
  $secretLength = 10,
  $base32 = null 
)

Initialises an RFC6238-compatible TOTP generator. Please note that this class does not implement the constraint in the last paragraph of §5.2 of RFC6238. It's up to you to ensure that the same user/device does not retry validation within the same Time Step.

Paramètres
int$timeStepThe Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
int$passCodeLengthThe generated passcode length. Default: 6 digits.
int$secretLengthThe length of the secret key. Default: 10 bytes (80 bits).
Object$base32The base32 en/decrypter

Documentation des fonctions membres

◆ checkCode()

checkCode (   $secret,
  $code 
)

Check is the given passcode $code is a valid TOTP generated using secret key $secret

Paramètres
string$secretThe Base32-encoded secret key
string$codeThe passcode to check
Renvoie
boolean True if the code is valid

Références $i.

◆ generateSecret()

generateSecret ( )

Generates a (semi-)random Secret Key for TOTP generation

Renvoie
string
Note
Since 3.9.25 we use the secure method "random_bytes" over the original insecure "rand" function. The random_bytes function has been backported to outdated PHP versions by the core shipped library paragonie/random_compat

◆ getCode()

getCode (   $secret,
  $time = null 
)

Gets the TOTP passcode for a given secret key $secret and a given UNIX timestamp $time

Paramètres
string$secretThe Base32-encoded secret key
int$timeUNIX timestamp
Renvoie
string

Références $hash, et Joomla\Database\Query\$offset.

◆ getPeriod()

getPeriod (   $time = null)

Get the time period based on the $time timestamp and the Time Step defined. If $time is skipped or set to null the current timestamp will be used.

Paramètres
int | null$timeTimestamp
Renvoie
integer The time period since the UNIX Epoch

◆ getUrl()

getUrl (   $user,
  $hostname,
  $secret 
)

Returns a QR code URL for easy setup of TOTP apps like Google Authenticator

Paramètres
string$userUser
string$hostnameHostname
string$secretSecret string
Renvoie
string

Références $url, et $user.

◆ hashToInt()

hashToInt (   $bytes,
  $start 
)
protected

Extracts a part of a hash as an integer

Paramètres
string$bytesThe hash
string$startThe char to start from (0 = first char)
Renvoie
string

Références $input, et $start.

Documentation des champs

◆ $_base32

$_base32 = null
private

◆ $_passCodeLength

$_passCodeLength = 6
private

◆ $_pinModulo

$_pinModulo
private

◆ $_secretLength

$_secretLength = 20
private

◆ $_timeStep

$_timeStep = 30
private

La documentation de cette classe a été générée à partir du fichier suivant :