MediaWiki  1.34.0
MediaWiki\Extension\OATHAuth\Key\TOTPKey Class Reference

Class representing a two-factor key. More...

Inheritance diagram for MediaWiki\Extension\OATHAuth\Key\TOTPKey:
Collaboration diagram for MediaWiki\Extension\OATHAuth\Key\TOTPKey:

Public Member Functions

 __construct ( $secret, array $scratchTokens)
 
 getScratchTokens ()
 
 getSecret ()
 
 isScratchToken ( $token)
 Check if a token is one of the scratch tokens for this two factor key. More...
 
 jsonSerialize ()
 
 regenerateScratchTokens ()
 
 verify ( $data, OATHUser $user)
 

Static Public Member Functions

static newFromArray (array $data)
 
static newFromRandom ()
 
static newFromString ( $data)
 Create key from json encoded string. More...
 

Public Attributes

const MAIN_TOKEN = 1
 Represents that a token corresponds to the main secret. More...
 
const SCRATCH_TOKEN = -1
 Represents that a token corresponds to a scratch token. More...
 

Private Member Functions

 getLogger ()
 

Private Attributes

string[] $scratchTokens = []
 List of scratch tokens. More...
 
array $secret
 Two factor binary secret. More...
 

Detailed Description

Class representing a two-factor key.

Keys can be tied to OATHUsers

Definition at line 41 of file TOTPKey.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::__construct (   $secret,
array  $scratchTokens 
)
Parameters
string$secret
array$scratchTokens

Definition at line 104 of file TOTPKey.php.

References MediaWiki\Extension\OATHAuth\Key\TOTPKey\$scratchTokens, and MediaWiki\Extension\OATHAuth\Key\TOTPKey\$secret.

Member Function Documentation

◆ getLogger()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::getLogger ( )
private
Returns
LoggerInterface

Definition at line 252 of file TOTPKey.php.

References MediaWiki\Logger\LoggerFactory\getInstance().

Referenced by MediaWiki\Extension\OATHAuth\Key\TOTPKey\verify().

◆ getScratchTokens()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::getScratchTokens ( )

◆ getSecret()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::getSecret ( )

◆ isScratchToken()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::isScratchToken (   $token)

Check if a token is one of the scratch tokens for this two factor key.

Parameters
string$tokenToken to verify
Returns
bool true if this is a scratch token.

Definition at line 244 of file TOTPKey.php.

◆ jsonSerialize()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::jsonSerialize ( )

◆ newFromArray()

static MediaWiki\Extension\OATHAuth\Key\TOTPKey::newFromArray ( array  $data)
static

◆ newFromRandom()

static MediaWiki\Extension\OATHAuth\Key\TOTPKey::newFromRandom ( )
static
Returns
TOTPKey
Exceptions
Exception

Definition at line 64 of file TOTPKey.php.

Referenced by MediaWiki\Extension\OATHAuth\HTMLForm\TOTPEnableForm\getDescriptors().

◆ newFromString()

static MediaWiki\Extension\OATHAuth\Key\TOTPKey::newFromString (   $data)
static

Create key from json encoded string.

Parameters
string$data
Returns
TOTPKey|null on invalid data

Definition at line 81 of file TOTPKey.php.

◆ regenerateScratchTokens()

MediaWiki\Extension\OATHAuth\Key\TOTPKey::regenerateScratchTokens ( )

◆ verify()

Member Data Documentation

◆ $scratchTokens

string [] MediaWiki\Extension\OATHAuth\Key\TOTPKey::$scratchTokens = []
private

◆ $secret

array MediaWiki\Extension\OATHAuth\Key\TOTPKey::$secret
private

Two factor binary secret.

Definition at line 55 of file TOTPKey.php.

Referenced by MediaWiki\Extension\OATHAuth\Key\TOTPKey\__construct().

◆ MAIN_TOKEN

const MediaWiki\Extension\OATHAuth\Key\TOTPKey::MAIN_TOKEN = 1

Represents that a token corresponds to the main secret.

See also
verify

Definition at line 46 of file TOTPKey.php.

Referenced by MediaWiki\Extension\OATHAuth\Key\TOTPKey\verify().

◆ SCRATCH_TOKEN

const MediaWiki\Extension\OATHAuth\Key\TOTPKey::SCRATCH_TOKEN = -1

Represents that a token corresponds to a scratch token.

See also
verify

Definition at line 52 of file TOTPKey.php.

Referenced by MediaWiki\Extension\OATHAuth\Key\TOTPKey\verify().


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