Documentation

Users_Totp_Authmethod
in package

Table of Contents

ALLOWED_USER_AUTHY_MODE  = ['TOTP_OFF', 'TOTP_OPTIONAL', 'TOTP_OBLIGATORY']
User authentication mode possible values.
$secret  : string
$userId  : int
__construct()  : mixed
Users_Totp_Authmethod constructor.
createQrCodeForUser()  : path|string
Create QR code for user.
createSecret()  : string
Creating a secret code for TOTP.
getOtpAuthUrl()  : string
Generate otaauth url for QR codes.
isActive()  : bool
Determine whether 2FA is required.
mustInit()  : bool
Check if 2FA initiation is necessary.
verifyCode()  : bool
2FA - verification of the code from the user.
createQrCode()  : path|string
Create QR code.

Constants

ALLOWED_USER_AUTHY_MODE

User authentication mode possible values.

public mixed ALLOWED_USER_AUTHY_MODE = ['TOTP_OFF', 'TOTP_OPTIONAL', 'TOTP_OBLIGATORY']

TOTP_OFF - 2FA TOTP is checking off TOTP_OPTIONAL - It is defined by the user TOTP_OBLIGATORY - It is obligatory.

Properties

$secret

private string $secret

$userId

private int $userId

Methods

__construct()

Users_Totp_Authmethod constructor.

public __construct(int $userId) : mixed
Parameters
$userId : int
  • Id of user
Return values
mixed

createQrCodeForUser()

Create QR code for user.

public createQrCodeForUser([string $type = 'PNG' ]) : path|string
Parameters
$type : string = 'PNG'
  • acceptable types [HTML, SVG, PNG]
Tags
throws
NotAllowedMethod
Return values
path|string

createSecret()

Creating a secret code for TOTP.

public createSecret() : string
Return values
string

getOtpAuthUrl()

Generate otaauth url for QR codes.

public getOtpAuthUrl(string $secret, string $name[, string|null $issuer = null ]) : string
Parameters
$secret : string
  • REQUIRED: The secret parameter is an arbitrary key value encoded in Base32 according to RFC 3548. The padding specified in RFC 3548 section 2.2 is not required and should be omitted.
$name : string
  • The name is used to identify which account a key is associated with.
$issuer : string|null = null
  • STRONGLY RECOMMENDED: The issuer parameter is a string value indicating the provider or service this account is associated with, URL-encoded according to RFC 3986.
Tags
see
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
Return values
string
  • otpauth url

isActive()

Determine whether 2FA is required.

public static isActive([int|null $userId = null ]) : bool
Parameters
$userId : int|null = null
  • if null then getCurrentUserRealId
Return values
bool

mustInit()

Check if 2FA initiation is necessary.

public static mustInit([int|null $userId = null ]) : bool
Parameters
$userId : int|null = null
  • if null then getCurrentUserRealId
Return values
bool

verifyCode()

2FA - verification of the code from the user.

public static verifyCode(string $secret, string $userCode) : bool
Parameters
$secret : string
$userCode : string
Return values
bool

createQrCode()

Create QR code.

private createQrCode(string $otpAuthUrl[, string $type = 'HTML' ]) : path|string
Parameters
$otpAuthUrl : string
$type : string = 'HTML'
  • acceptable types [HTML, SVG, PNG]
Tags
throws
NotAllowedMethod
Return values
path|string
  • HTML code

Search results