Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
tool_mfa\manager Class Reference

Static Public Member Functions

static cannot_login ()
 Function to display to the user that they cannot login, then log them out.
 
static check_factor_pending (string $factorname)
 Checks whether the factor was actually used in the login process.
 
static clear_redirect_counter ()
 Clears the redirect counter for infinite redirect loops.
 
static display_debug_notification ()
 Displays a debug table with current factor information.
 
static do_factor_action (string $factorname, string $action)
 Performs factor actions for given factor.
 
static get_cumulative_weight ()
 Gets current user weight, up until first unknown factor.
 
static get_no_redirect_urls ()
 Gets all defined factor urls that should not redirect.
 
static get_status ()
 Function to get the overall status of a user's authentication.
 
static get_total_weight ()
 Returns the total weight from all factors currently enabled for user.
 
static is_factorid_valid (int $factorid, object $user)
 Checks that provided factorid exists and belongs to current user.
 
static is_ready ()
 Checks if MFA Plugin is enabled and has enabled factor.
 
static mfa_logout ()
 Logout user.
 
static passed_enough_factors ()
 Checks whether user has passed enough factors to be allowed in.
 
static possible_factor_setup ()
 Checks if a factor that can make a user pass can be setup.
 
static require_auth ($courseorid=null, $autologinguest=null, $cm=null, $setwantsurltome=null, $preventredirect=null)
 If MFA Plugin is ready check tool_mfa_authenticated USER property and start MFA authentication if it's not set or false.
 
static resolve_mfa_status (bool $shouldreload=false)
 Function to check the overall status of a users authentication, and perform any required actions.
 
static set_factor_config (array $data, string $factor)
 Sets config variable for given factor.
 
static set_pass_state ()
 Sets the session variable for pass_state, if not already set.
 
static should_require_mfa (string|moodle_url $url, bool|null $preventredirect)
 Checks whether the user should be redirected from the provided url.
 
static sleep_timer ()
 Sleeps for an increasing period of time.
 

Public Attributes

int const NO_REDIRECT = 0
 
int const REDIR_LOOP_THRESHOLD = 5
 
int const REDIRECT = 1
 
int const REDIRECT_EXCEPTION = -1
 

Member Function Documentation

◆ cannot_login()

static tool_mfa\manager::cannot_login ( )
static

Function to display to the user that they cannot login, then log them out.

Return values
void

◆ check_factor_pending()

static tool_mfa\manager::check_factor_pending ( string $factorname)
static

Checks whether the factor was actually used in the login process.

Parameters
string$factornamethe name of the factor.
Return values
booltrue if factor is pending.

◆ clear_redirect_counter()

static tool_mfa\manager::clear_redirect_counter ( )
static

Clears the redirect counter for infinite redirect loops.

Called from auth.php when a valid load is resolved.

Return values
void

◆ display_debug_notification()

static tool_mfa\manager::display_debug_notification ( )
static

Displays a debug table with current factor information.

Return values
void

◆ do_factor_action()

static tool_mfa\manager::do_factor_action ( string $factorname,
string $action )
static

Performs factor actions for given factor.

Change factor order and enable/disable.

Parameters
string$factorname
string$action
Return values
void
Exceptions
dml_exception

◆ get_cumulative_weight()

static tool_mfa\manager::get_cumulative_weight ( )
static

Gets current user weight, up until first unknown factor.

Return values
int\$totalweightTotal weight of all factors.

◆ get_no_redirect_urls()

static tool_mfa\manager::get_no_redirect_urls ( )
static

Gets all defined factor urls that should not redirect.

Return values
array

◆ get_status()

static tool_mfa\manager::get_status ( )
static

Function to get the overall status of a user's authentication.

Return values
stringa STATE variable from plugininfo

◆ get_total_weight()

static tool_mfa\manager::get_total_weight ( )
static

Returns the total weight from all factors currently enabled for user.

Return values
int

◆ is_factorid_valid()

static tool_mfa\manager::is_factorid_valid ( int $factorid,
object $user )
static

Checks that provided factorid exists and belongs to current user.

Parameters
int$factorid
object$user
Return values
bool
Exceptions
dml_exception

◆ is_ready()

static tool_mfa\manager::is_ready ( )
static

Checks if MFA Plugin is enabled and has enabled factor.

If plugin is disabled or there is no enabled factors, it means there is nothing to do from user side. Thus, login flow shouldn't be extended with MFA.

Return values
bool
Exceptions
dml_exception

◆ mfa_logout()

static tool_mfa\manager::mfa_logout ( )
static

Logout user.

Return values
void

◆ passed_enough_factors()

static tool_mfa\manager::passed_enough_factors ( )
static

Checks whether user has passed enough factors to be allowed in.

Return values
booltrue if user has passed enough factors.

◆ possible_factor_setup()

static tool_mfa\manager::possible_factor_setup ( )
static

Checks if a factor that can make a user pass can be setup.

It checks if a user will always pass regardless, then checks if there are factors that can be setup to let a user pass.

Return values
bool

◆ require_auth()

static tool_mfa\manager::require_auth ( $courseorid = null,
$autologinguest = null,
$cm = null,
$setwantsurltome = null,
$preventredirect = null )
static

If MFA Plugin is ready check tool_mfa_authenticated USER property and start MFA authentication if it's not set or false.

Parameters
mixed$courseorid
mixed$autologinguest
mixed$cm
mixed$setwantsurltome
mixed$preventredirect
Return values
void

◆ resolve_mfa_status()

static tool_mfa\manager::resolve_mfa_status ( bool $shouldreload = false)
static

Function to check the overall status of a users authentication, and perform any required actions.

Parameters
bool$shouldreloadwhether the function should reload (used for auth.php).
Return values
void

◆ set_factor_config()

static tool_mfa\manager::set_factor_config ( array $data,
string $factor )
static

Sets config variable for given factor.

Parameters
array$data
string$factor
Return values
booltrue or exception
Exceptions
dml_exception

◆ set_pass_state()

static tool_mfa\manager::set_pass_state ( )
static

Sets the session variable for pass_state, if not already set.

Return values
void

◆ should_require_mfa()

static tool_mfa\manager::should_require_mfa ( string|moodle_url $url,
bool|null $preventredirect )
static

Checks whether the user should be redirected from the provided url.

Parameters
string | moodle_url$url
bool | null$preventredirect
Return values
int

◆ sleep_timer()

static tool_mfa\manager::sleep_timer ( )
static

Sleeps for an increasing period of time.

Return values
void

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