CaMykS  1.0-20231201
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CodeAuthenticator Class Reference

CodeAuthenticator input
Handles 2-factor with code authenticator authentication.
Highly based on PHPGangsta / GoogleAuthenticator library (https://github.com/PHPGangsta/GoogleAuthenticator) More...

Inheritance diagram for CodeAuthenticator:
Input Plugin

Public Member Functions

 __construct ($path_type)
 
 initialise ($params=array())
 
 execute_request ()
 
 prepare_userConfiguration ($params)
 
 display_userConfiguration ()
 
 confirm_userConfiguration ()
 
 reset_userConfigurationData ()
 
 prepare_userLogin ($params)
 
 display_userLogin ()
 
 confirm_userLogin ($params)
 
 create_secret ()
 
 get_code ($secret, $timeSlice=null)
 
 verify_code ($secret, $code, $discrepancy=1, $currentTimeSlice=null)
 
 get_QRCodeURL ()
 
 get_lastError ()
 
 execute_onCaMykSPageLoad ()
 
 initialise_configDisplay ()
 
 display_configDisplay ()
 
 initialise_configEdition ($form)
 
 display_configEdition ()
 
 save_configuration ()
 
- Public Member Functions inherited from Input
 __construct ($name, $path_type)
 
 Input ($name, $path_type)
 
 display ()
 
 get_translation ($value, $data=null)
 
 set_selectedLayout ($layout='')
 
- Public Member Functions inherited from Plugin
 __construct ($name, $plugin_type, $path_type)
 
 get_version ()
 
 load_library ($library='')
 
 load_file ($file='')
 
 load_varFile ($file='')
 
 load_engineFile ($file='')
 
 get_engineFileURL ($file='', $path=false)
 
 get_fileURL ($file='', $path=null, $default='')
 
 get_varFileURL ($file='', $path=false, $default='')
 
 get_filePath ($file='')
 
 get_varFilePath ($file='')
 
 add_JSFile ($file)
 
 add_JSEngineFile ($file)
 
 add_JSExternFile ($file)
 
 add_JSScript ($script, $unique=false)
 
 add_JSPreScript ($script, $unique=false)
 
 add_JSWindowEventScript ($event, $script, $unique=false)
 
 add_JSLoadScript ($script, $unique=false)
 
 add_JSUnloadScript ($script, $unique=false)
 
 add_styleFile ($file, $media='', $condition='')
 
 add_styleScript ($css)
 
 add_styleIncludedFile ($file)
 
 add_StyleExternFile ($file, $media='', $condition='')
 
 set_RSSFeed ($title, $url)
 
 add_headerExtra ($content='')
 
 install ()
 
 uninstall ()
 
 is_installed ()
 
 update ($version, $more='')
 
 add_translation ($more='', $lg=null)
 
 get_languages ()
 
 execute_onCaMykSInitialise ()
 
 execute_onCaMykSBodyOpen ()
 
 execute_onCaMykSBodyClose ()
 
 execute_onCaMykSAdminPageLoad ()
 
 execute_onCaMykSAdminBodyOpen ()
 
 execute_onCaMykSAdminBodyClose ()
 
 execute_onCaMykSTerminate ()
 
 get_requestLink ($params=array())
 
 get_requestJSLink ($params=array())
 
 get_varFile ($file)
 

Protected Member Functions

 get_configValue ($name='')
 
- Protected Member Functions inherited from Plugin
 set_redirect ($time, $url='')
 
 add_meta ($name, $content, $method='name')
 
 add_toHtaccess ($content='')
 
 add_dependency ($plugin, $type, $version='1.0', $mandatory=false)
 
 set_dependencies ()
 
 register_asSharedObject ($name)
 
get_sharedObject ($name)
 
 register_asExtension ($plugin)
 
 get_registeredExtensions ()
 
 register_asCaMykSEventHandler ($event)
 

Protected Attributes

 $config
 Input configuration. More...
 
 $isConfigLoaded = false
 Stores if the configuration is loaded. More...
 

Private Member Functions

 execute_request_QRCodePicture ()
 
 load_configuration ()
 
 decode_base32 ($secret)
 
 get_base32LookupTable ()
 
 get_timeSlice ()
 
 is_timingSafeEqual ($safeString, $userString)
 
 set_lastError ($error)
 

Private Attributes

 $lastError = 0
 Last error. More...
 

Additional Inherited Members

- Public Attributes inherited from Input
 $title
 Input title. More...
 
 $params = array()
 Input parameters. More...
 
 $selected_layout = 'input.html.inc'
 Input layout to use. More...
 
- Public Attributes inherited from Plugin
 $name
 Plugin name. More...
 
 $version
 Plugin version. More...
 
 $active = false
 Plugin installation status. More...
 
 $plugin_package = ''
 Plugin package. More...
 
 $plugin_type
 Plugin type. More...
 
 $object_type
 Plugin type. More...
 
 $plugin_path
 Plugin path. More...
 
 $plugin_site_path
 Plugin site path (for element overwriting). More...
 
 $plugin_var_path
 Plugin var path. More...
 
 $plugin_url
 Plugin URL. More...
 
 $plugin_site_url
 Plugin site URL (for element overwriting). More...
 
 $plugin_var_url
 Plugin var URL. More...
 
 $path_type
 Plugin path type. More...
 
 $author_name
 Plugin author name. More...
 
 $author_mail
 Plugin author email. More...
 
 $author_group
 Plugin author group. More...
 
 $plugin_dependencies = array()
 Plugin dependencies. More...
 

Detailed Description

CodeAuthenticator input
Handles 2-factor with code authenticator authentication.
Highly based on PHPGangsta / GoogleAuthenticator library (https://github.com/PHPGangsta/GoogleAuthenticator)

Engine / Object Library

Author
CaMykS Team camyk.nosp@m.s.co.nosp@m.ntact.nosp@m.@gma.nosp@m.il.co.nosp@m.m
Version
1.0.1
Date
Creation: Jun 2021
Modification: Jul 2021
Note
This program is distributed as is - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. CodeAuthenticator Input class.

Constructor & Destructor Documentation

◆ __construct()

CodeAuthenticator::__construct (   $path_type)

Class constructor.

Parameters
string$path_type
Returns
void

Member Function Documentation

◆ initialise()

CodeAuthenticator::initialise (   $params = array())

Initialise input.

Parameters
array$params
Returns
void

Reimplemented from Input.

◆ execute_request()

CodeAuthenticator::execute_request ( )

Execute module object in request mode.

Returns
void

Reimplemented from Plugin.

◆ execute_request_QRCodePicture()

CodeAuthenticator::execute_request_QRCodePicture ( )
private

Write QR Code as picture.

Returns
void

◆ prepare_userConfiguration()

CodeAuthenticator::prepare_userConfiguration (   $params)

Prepare 2FA configuration for user. return void

◆ display_userConfiguration()

CodeAuthenticator::display_userConfiguration ( )

Display 2FA configuration for user.

Returns
void

◆ confirm_userConfiguration()

CodeAuthenticator::confirm_userConfiguration ( )

Confirm 2FA configuration for user.

Returns
string

◆ reset_userConfigurationData()

CodeAuthenticator::reset_userConfigurationData ( )

Reset 2FA configuration data for user.

Returns
string

◆ prepare_userLogin()

CodeAuthenticator::prepare_userLogin (   $params)

Prepare 2FA login for user. return void

◆ display_userLogin()

CodeAuthenticator::display_userLogin ( )

Display 2FA login for user.

Returns
void

◆ confirm_userLogin()

CodeAuthenticator::confirm_userLogin (   $params)

Confirm 2FA login for user.

Returns
string

◆ load_configuration()

CodeAuthenticator::load_configuration ( )
private

Load configuration.

Returns
void

◆ get_configValue()

CodeAuthenticator::get_configValue (   $name = '')
protected

Return configuration value.

Parameters
string$name
Returns
mixed

◆ create_secret()

CodeAuthenticator::create_secret ( )

Create new secret.

Returns
string

◆ get_code()

CodeAuthenticator::get_code (   $secret,
  $timeSlice = null 
)

Calculate the code, with given secret and point in time.

Parameters
string$secret
int | null$timeSlice
Returns
string

◆ verify_code()

CodeAuthenticator::verify_code (   $secret,
  $code,
  $discrepancy = 1,
  $currentTimeSlice = null 
)

Check if the given code is correct.

Parameters
string$secret
string$code
int$discrepancy
int | null$currentTimeSlicetime slice if we want use other that time()
Returns
boolean success

◆ get_QRCodeURL()

CodeAuthenticator::get_QRCodeURL ( )

Return QR Code URL.

Returns
string

◆ decode_base32()

CodeAuthenticator::decode_base32 (   $secret)
private

Return decoded base32 secret.

Parameters
$secret
Returns
bool|string

◆ get_base32LookupTable()

CodeAuthenticator::get_base32LookupTable ( )
private

Get array with all 32 characters for decoding from/encoding to base32.

Returns
array

◆ get_timeSlice()

CodeAuthenticator::get_timeSlice ( )
private

Return default time slice.

Returns
integer

◆ is_timingSafeEqual()

CodeAuthenticator::is_timingSafeEqual (   $safeString,
  $userString 
)
private

Check timings with a safe equal comparison

Parameters
string$safeString
string$userString
Returns
boolean result

◆ get_lastError()

CodeAuthenticator::get_lastError ( )

Return last error message.

Returns
string

◆ set_lastError()

CodeAuthenticator::set_lastError (   $error)
private

Define last error

Parameters
integer$error
Returns
void

◆ execute_onCaMykSPageLoad()

CodeAuthenticator::execute_onCaMykSPageLoad ( )

Execute handler on page loading.

Returns
void

Reimplemented from Plugin.

◆ initialise_configDisplay()

CodeAuthenticator::initialise_configDisplay ( )

Initialise object in Admin_Site / view configuration mode.

Returns
void

◆ display_configDisplay()

CodeAuthenticator::display_configDisplay ( )

Display object in Admin_Site / view configuration mode.

Returns
void

◆ initialise_configEdition()

CodeAuthenticator::initialise_configEdition (   $form)

Initialise object in Admin_Site / edit configuration mode.

Parameters
Object$form
Returns
void

◆ display_configEdition()

CodeAuthenticator::display_configEdition ( )

Display object in Admin_Site / edit configuration mode.

Returns
void

◆ save_configuration()

CodeAuthenticator::save_configuration ( )

Execute object in Admin_Site / save configuration mode.

Returns
void

Member Data Documentation

◆ $config

CodeAuthenticator::$config
protected

Input configuration.

var Object $config

◆ $isConfigLoaded

CodeAuthenticator::$isConfigLoaded = false
protected

Stores if the configuration is loaded.

var boolean isConfigLoaded

◆ $lastError

integer CodeAuthenticator::$lastError = 0
private

Last error.


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