Documentation

totp_functions.php

Table of Contents

Functions

TOTP_validate()  : bool
Validates a TOTP code for the given user reference.
TOTP_cookie()  : string
Generates a daily cookie hash based on the user reference and scramble key.
TOTP_is_user_set_up()  : bool
Checks whether TOTP is set up for the specified user.
TOTP_get_secret()  : string
Generates the TOTP secret for the given user.
TOTP_get_url()  : string
Constructs the otpauth URL for the user's TOTP setup.
TOTP_setup_complete()  : void
Marks TOTP setup as complete for the specified user.
TOTP_tries()  : int
Retrieves the number of failed TOTP attempts for the user.
TOTP_increase_tries()  : void
Increments the TOTP attempt counter for the specified user.
TOTP_saml_authenticate()  : bool
Checks to see if SAML is authenticated for the given user if TOTP can be skipped for SAML users.

Functions

TOTP_validate()

Validates a TOTP code for the given user reference.

TOTP_validate(string $code, int $user_ref) : bool
Parameters
$code : string

The TOTP code to validate.

$user_ref : int

The user reference.

Return values
bool

True if the code is valid, false otherwise.

Generates a daily cookie hash based on the user reference and scramble key.

TOTP_cookie(int $user_ref) : string
Parameters
$user_ref : int

The user reference.

Return values
string

A SHA-256 hash used for TOTP cookie validation.

TOTP_is_user_set_up()

Checks whether TOTP is set up for the specified user.

TOTP_is_user_set_up(int $user_ref) : bool
Parameters
$user_ref : int

The user reference.

Return values
bool

True if TOTP is set up, false otherwise.

TOTP_get_secret()

Generates the TOTP secret for the given user.

TOTP_get_secret(int $user_ref) : string
Parameters
$user_ref : int

The user reference.

Return values
string

A base32-encoded TOTP secret.

TOTP_get_url()

Constructs the otpauth URL for the user's TOTP setup.

TOTP_get_url(int $user_ref) : string
Parameters
$user_ref : int

The user reference.

Return values
string

The otpauth URL used to generate a QR code in authenticator apps.

TOTP_setup_complete()

Marks TOTP setup as complete for the specified user.

TOTP_setup_complete(int $user_ref) : void
Parameters
$user_ref : int

The user reference.

TOTP_tries()

Retrieves the number of failed TOTP attempts for the user.

TOTP_tries(int $user_ref) : int
Parameters
$user_ref : int

The user reference.

Return values
int

The number of TOTP validation attempts.

TOTP_increase_tries()

Increments the TOTP attempt counter for the specified user.

TOTP_increase_tries(int $user_ref) : void
Parameters
$user_ref : int

The user reference.

TOTP_saml_authenticate()

Checks to see if SAML is authenticated for the given user if TOTP can be skipped for SAML users.

TOTP_saml_authenticate() : bool
Return values
bool

True if SAML is enabled and authenticates, false otherwise

On this page

Search results