TimeTrex API Manual

Authentication
in package

Table of Contents

$cache  : Cache_Lite_Function|Cache_Lite_Output
$client_id  : mixed
$created_date  : mixed
$db  : mixed
$end_point_id  : mixed
$expire_session  : mixed
$flags  : mixed
$idle_timeout  : mixed
$ip_address  : mixed
$name  : mixed
$obj  : mixed
$object_id  : mixed
$rl  : mixed
$session_id  : mixed
$type_id  : mixed
$updated_date  : mixed
$user_agent  : mixed
__construct()  : mixed
Authentication constructor.
changeObject()  : bool
Check()  : bool
checkApplicantPassword()  : bool
checkBarcode()  : bool
checkClientPC()  : bool
checkCompanyStatus()  : bool
checkFingerPrint()  : bool
checkIButton()  : bool
checkPassword()  : bool
checkPhonePassword()  : bool
checkUsername()  : bool
Checks just the username, used in conjunction with HTTP Authentication/SSO.
checkValidCSRFToken()  : bool
Checks that the CSRF token header matches the CSRF token cookie that was originally sent.
encryptSessionID()  : string
#2238 - Encrypt SessionID with private SALT before writing/reading SessionID in database.
getClientID()  : string
getClientIDHeader()  : bool|string
Returns the value of the X-Client-ID HTTP header so we can determine what type of front-end we are using and if CSRF checks should be enabled or not.
getCompanyObject()  : bool|mixed
getCreatedDate()  : null
getCurrentSessionID()  : string|bool
Gets the current session ID from the COOKIE, POST or GET variables.
getEnableExpireSession()  : mixed
getEndPointID()  : string
getHTTPAuthenticationUsername()  : bool
getIdleTimeout()  : int
getIPAddress()  : null
getName()  : bool|mixed
getNameByTypeId()  : bool|mixed
getObject()  : bool|null
getObjectByID()  : bool
getObjectID()  : null
getRateLimitObject()  : mixed|object|RateLimit
getSecureSessionID()  : mixed
getSessionID()  : string|null
getType()  : int
getTypeIDByName()  : bool|int
getUpdatedDate()  : null
getUserAgent()  : string
HTTPAuthenticationHeader()  : mixed
isSessionIDAPIKey()  : bool
isUser()  : bool
Determine if the session type is for an actual user, so we know if we can create audit logs.
Login()  : bool
loginHTTPAuthentication()  : bool
Allow web server to handle authentication with Basic Auth/LDAP/SSO/AD, etc.
Logout()  : bool
logoutCompany()  : bool
When company status changes, logout all users for the company.
logoutUser()  : bool
When user resets or changes their password, logout all sessions for that user.
newSession()  : null
Duplicates existing session with a new SessionID. Useful for multiple logins with the same or different users.
parseEndPointID()  : mixed|string
registerAPIKey()  : bool|string
Register permanent API key Session ID to be used for all subsequent API calls without needing a username/password.
setClientID()  : bool
setCreatedDate()  : bool
setEnableExpireSession()  : bool
setEndPointID()  : bool
setIdleTimeout()  : bool
setIPAddress()  : bool
setObject()  : bool
setObjectID()  : bool
setSessionID()  : bool
setType()  : bool
setUpdatedDate()  : bool
setUserAgent()  : bool
Delete()  : bool
destroyCookie()  : bool
genSessionID()  : string
Read()  : bool
setCookie()  : bool
Update()  : bool
UpdateLastLoginDate()  : bool
Write()  : bool

Properties

Methods

__construct()

Authentication constructor.

public __construct() : mixed
Return values
mixed

changeObject()

public changeObject(string $object_id) : bool
Parameters
$object_id : string

UUID

Tags
throws
DBError
Return values
bool

Check()

public Check([string $session_id = null ][, string $type = null ][, bool $touch_updated_date = true ]) : bool
Parameters
$session_id : string = null

UUID

$type : string = null
$touch_updated_date : bool = true
Tags
throws
DBError
Return values
bool

checkApplicantPassword()

public checkApplicantPassword( $user_name,  $password) : bool
Parameters
$user_name :
$password :
Return values
bool

checkBarcode()

public checkBarcode(string $object_id,  $employee_number) : bool
Parameters
$object_id : string

UUID

$employee_number :
Return values
bool

checkClientPC()

public checkClientPC( $user_name) : bool
Parameters
$user_name :
Return values
bool

checkCompanyStatus()

public checkCompanyStatus( $user_name) : bool
Parameters
$user_name :
Return values
bool

checkFingerPrint()

public checkFingerPrint(string $id) : bool
Parameters
$id : string

UUID

Return values
bool

checkIButton()

public checkIButton(string $id) : bool
Parameters
$id : string

UUID

Return values
bool

checkPassword()

public checkPassword( $user_name,  $password) : bool
Parameters
$user_name :
$password :
Return values
bool

checkPhonePassword()

public checkPhonePassword(int $phone_id,  $password) : bool
Parameters
$phone_id : int
$password :
Return values
bool

checkUsername()

Checks just the username, used in conjunction with HTTP Authentication/SSO.

public checkUsername( $user_name) : bool
Parameters
$user_name :
Return values
bool

checkValidCSRFToken()

Checks that the CSRF token header matches the CSRF token cookie that was originally sent.

public checkValidCSRFToken() : bool

This uses the Cookie-To-Header method explained here: https://en.wikipedia.org/w/index.php?title=Cross-site_request_forgery#Cookie-to-header_token Also explained further here: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html -- "Double Submit Cookie" method.

Return values
bool

encryptSessionID()

#2238 - Encrypt SessionID with private SALT before writing/reading SessionID in database.

public encryptSessionID(string $session_id) : string

This adds an additional protection layer against session stealing if a SQL injection attack is ever discovered. It prevents someone from being able to enumerate over the SessionIDs in the table and use them for nafarious purposes.

Parameters
$session_id : string

UUID

Return values
string

getClientIDHeader()

Returns the value of the X-Client-ID HTTP header so we can determine what type of front-end we are using and if CSRF checks should be enabled or not.

public getClientIDHeader() : bool|string
Return values
bool|string

getCompanyObject()

public getCompanyObject( $user_name[, string $type = 'USER' ]) : bool|mixed
Parameters
$user_name :
$type : string = 'USER'
Return values
bool|mixed

getCurrentSessionID()

Gets the current session ID from the COOKIE, POST or GET variables.

public getCurrentSessionID(string $type) : string|bool
Parameters
$type : string
Return values
string|bool

getEnableExpireSession()

public getEnableExpireSession() : mixed
Return values
mixed

getEndPointID()

public getEndPointID([mixed $end_point_id = null ]) : string
Parameters
$end_point_id : mixed = null
Return values
string

getHTTPAuthenticationUsername()

public getHTTPAuthenticationUsername() : bool
Return values
bool

getName()

public getName([bool $type_id = false ]) : bool|mixed
Parameters
$type_id : bool = false
Return values
bool|mixed

getNameByTypeId()

public getNameByTypeId(int $type_id) : bool|mixed
Parameters
$type_id : int
Return values
bool|mixed

getObjectByID()

public getObjectByID(string $id) : bool
Parameters
$id : string

UUID

Return values
bool

getTypeIDByName()

public getTypeIDByName( $type) : bool|int
Parameters
$type :
Return values
bool|int

HTTPAuthenticationHeader()

public HTTPAuthenticationHeader() : mixed
Return values
mixed

isSessionIDAPIKey()

public isSessionIDAPIKey( $session_id) : bool
Parameters
$session_id :
Return values
bool

isUser()

Determine if the session type is for an actual user, so we know if we can create audit logs.

public isUser([bool $type_id = false ]) : bool
Parameters
$type_id : bool = false
Return values
bool

Login()

public Login( $user_name,  $password[, string $type = 'USER_NAME' ][, mixed $enable_cookie = true ]) : bool
Parameters
$user_name :
$password :
$type : string = 'USER_NAME'
$enable_cookie : mixed = true
Tags
throws
DBError
Return values
bool

loginHTTPAuthentication()

Allow web server to handle authentication with Basic Auth/LDAP/SSO/AD, etc.

public loginHTTPAuthentication() : bool

..

Return values
bool

logoutCompany()

When company status changes, logout all users for the company.

public logoutCompany(string $company_id[, mixed $client_id = null ]) : bool
Parameters
$company_id : string

UUID

$client_id : mixed = null
Tags
throws
DBError
Return values
bool

logoutUser()

When user resets or changes their password, logout all sessions for that user.

public logoutUser(string $object_id[, string $type_id = 'USER_NAME' ][, bool $ignore_current_session = true ]) : bool
Parameters
$object_id : string

UUID

$type_id : string = 'USER_NAME'
$ignore_current_session : bool = true

Avoid logging out existing session, for example when the user is changing their own password.

Tags
throws
DBError
Return values
bool

newSession()

Duplicates existing session with a new SessionID. Useful for multiple logins with the same or different users.

public newSession([string $object_id = null ][, string $ip_address = null ][, string $user_agent = null ][, string $client_id = null ][, string $end_point_id = null ][, null $type_id = null ]) : null
Parameters
$object_id : string = null

UUID

$ip_address : string = null
$user_agent : string = null
$client_id : string = null

UUID

$end_point_id : string = null
$type_id : null = null
Tags
throws
DBError
Return values
null

parseEndPointID()

public parseEndPointID([null $end_point_id = null ]) : mixed|string
Parameters
$end_point_id : null = null
Return values
mixed|string

registerAPIKey()

Register permanent API key Session ID to be used for all subsequent API calls without needing a username/password.

public registerAPIKey(string $user_name, string $password[, mixed $end_point = null ]) : bool|string
Parameters
$user_name : string
$password : string
$end_point : mixed = null
Tags
throws
DBError
Return values
bool|string

setClientID()

public setClientID( $value) : bool
Parameters
$value :
Return values
bool

setCreatedDate()

public setCreatedDate([int $epoch = null ]) : bool
Parameters
$epoch : int = null

EPOCH

Return values
bool

setEnableExpireSession()

public setEnableExpireSession( $bool) : bool
Parameters
$bool :
Return values
bool

setEndPointID()

public setEndPointID( $value) : bool
Parameters
$value :
Return values
bool

setIdleTimeout()

public setIdleTimeout( $secs) : bool
Parameters
$secs :
Return values
bool

setIPAddress()

public setIPAddress([null $ip_address = null ]) : bool
Parameters
$ip_address : null = null
Return values
bool

setObject()

public setObject( $object) : bool
Parameters
$object :
Return values
bool

setObjectID()

public setObjectID(string $id) : bool
Parameters
$id : string

UUID

Return values
bool

setSessionID()

public setSessionID(string $session_id) : bool
Parameters
$session_id : string

UUID

Return values
bool

setType()

public setType(int $type_id) : bool
Parameters
$type_id : int
Return values
bool

setUpdatedDate()

public setUpdatedDate([int $epoch = null ]) : bool
Parameters
$epoch : int = null

EPOCH

Return values
bool

setUserAgent()

public setUserAgent( $value[, bool $hash = false ]) : bool
Parameters
$value :
$hash : bool = false
Return values
bool

setCookie()

private setCookie([bool $type_id = false ]) : bool
Parameters
$type_id : bool = false
Return values
bool

Search results