MediaWiki REL1_33
OATHAuthKey Class Reference

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

Collaboration diagram for OATHAuthKey:

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.
 
 regenerateScratchTokens ()
 
 verifyToken ( $token, OATHUser $user)
 Verify a token against the secret or scratch tokens.
 

Static Public Member Functions

static newFromRandom ()
 Make a new key from random values.
 

Public Attributes

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

Private Member Functions

 getLogger ()
 

Private Attributes

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

Detailed Description

Class representing a two-factor key.

Keys can be tied to OATHUsers

Definition at line 29 of file OATHAuthKey.php.

Constructor & Destructor Documentation

◆ __construct()

OATHAuthKey::__construct ( $secret,
array $scratchTokens )
Parameters
string$secret
array$scratchTokens

Definition at line 68 of file OATHAuthKey.php.

References $scratchTokens, and $secret.

Member Function Documentation

◆ getLogger()

OATHAuthKey::getLogger ( )
private
Returns
LoggerInterface

Definition at line 215 of file OATHAuthKey.php.

Referenced by verifyToken().

◆ getScratchTokens()

OATHAuthKey::getScratchTokens ( )
Returns
array

Definition at line 89 of file OATHAuthKey.php.

References $scratchTokens.

Referenced by SpecialOATHEnable\getScratchTokensForDisplay().

◆ getSecret()

OATHAuthKey::getSecret ( )
Returns
string

Definition at line 82 of file OATHAuthKey.php.

Referenced by SpecialOATHEnable\getSecretForDisplay().

◆ isScratchToken()

OATHAuthKey::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 207 of file OATHAuthKey.php.

References and().

◆ newFromRandom()

static OATHAuthKey::newFromRandom ( )
static

Make a new key from random values.

Returns
OATHAuthKey

Definition at line 53 of file OATHAuthKey.php.

References and(), and Base32\encode().

Referenced by SpecialOATHEnable\getFormFields().

◆ regenerateScratchTokens()

OATHAuthKey::regenerateScratchTokens ( )

Definition at line 192 of file OATHAuthKey.php.

References $scratchTokens, and(), and Base32\encode().

◆ verifyToken()

OATHAuthKey::verifyToken ( $token,
OATHUser $user )

Verify a token against the secret or scratch tokens.

Parameters
string$tokenToken to verify
OATHUser$user
Returns
int|false Returns a constant represent what type of token was matched, or false for no match

Definition at line 102 of file OATHAuthKey.php.

References and(), Base32\decode(), HOTP\generateByTimeWindow(), getLogger(), OATHAuthHooks\getOATHUserRepository(), MAIN_TOKEN, SCRATCH_TOKEN, and wfMemcKey().

Member Data Documentation

◆ $scratchTokens

string [] OATHAuthKey::$scratchTokens
private

List of scratch tokens.

Definition at line 46 of file OATHAuthKey.php.

Referenced by __construct(), getScratchTokens(), and regenerateScratchTokens().

◆ $secret

array OATHAuthKey::$secret
private

Two factor binary secret.

Definition at line 43 of file OATHAuthKey.php.

Referenced by __construct().

◆ MAIN_TOKEN

const OATHAuthKey::MAIN_TOKEN = 1

Represents that a token corresponds to the main secret.

See also
verifyToken

Definition at line 34 of file OATHAuthKey.php.

Referenced by verifyToken().

◆ SCRATCH_TOKEN

const OATHAuthKey::SCRATCH_TOKEN = -1

Represents that a token corresponds to a scratch token.

See also
verifyToken

Definition at line 40 of file OATHAuthKey.php.

Referenced by verifyToken().


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