Bitrix-D7 22.6
 
Загрузка...
Поиск...
Не найдено
Класс Otp

Открытые члены

 __construct ($algorithm=null)
 
 setType ($type)
 
 getType ()
 
 getProvisioningUri (array $opts=array())
 
 regenerate ($newSecret=null)
 
 verify ($input, $updateParams=true)
 
 isAttemptsReached ()
 
 getSyncParameters ($inputA, $inputB)
 
 syncParameters ($inputA, $inputB=null)
 
 save ()
 
 delete ()
 
 activate ()
 
 deactivate ($days=0)
 
 defer ($days=0)
 
 setUserInfo (array $userInfo)
 
 getInitialDate ()
 
 getDeactivateUntil ()
 
 isMandatorySkipped ()
 
 getUserId ()
 
 setActive ($isActive)
 
 isActivated ()
 
 setUserActive ($isActive)
 
 isUserActive ()
 
 isInitialized ()
 
 getAttempts ()
 
 getParams ()
 
 getSecret ()
 
 getHexSecret ()
 
 getAppSecret ()
 
 setSecret ($secret)
 
 setHexSecret ($hexValue)
 
 setAppSecret ($value)
 
 getIssuer ()
 
 setIssuer ($issuer)
 
 getLabel ($issuer=null)
 
 setLabel ($label)
 
 getContext ()
 
 setContext (\Bitrix\Main\Context $context)
 
 setUserLogin ($login)
 
 getUserLogin ()
 
 canSkipMandatory ()
 
 canSkipMandatoryByRights ()
 

Открытые статические члены

static getByUser ($userId)
 
static getByType ($type)
 
static verifyUser (array $params)
 
static isOtpRequired ()
 
static isOtpRequiredByMandatory ()
 
static isCaptchaRequired ()
 
static getDeferredParams ()
 
static setDeferredParams ($params)
 
static setSkipMandatoryDays ($days=2)
 
static getSkipMandatoryDays ()
 
static setMandatoryUsing ($isMandatory=true)
 
static isMandatoryUsing ()
 
static setMandatoryRights (array $rights)
 
static getMandatoryRights ()
 
static setDefaultType ($value)
 
static getDefaultType ()
 
static getAvailableTypes ()
 
static getTypesDescription ()
 
static isOtpEnabled ()
 
static isRecoveryCodesEnabled ()
 

Открытые атрибуты

const TYPE_HOTP = 'hotp'
 
const TYPE_TOTP = 'totp'
 
const TYPE_DEFAULT = self::TYPE_HOTP
 
const SECRET_LENGTH = 20
 
const SKIP_COOKIE = 'OTPH'
 
const REJECTED_KEY = 'OTP_REJECT_REASON'
 
const REJECT_BY_CODE = 'code'
 
const REJECT_BY_MANDATORY = 'mandatory'
 
const TAGGED_CACHE_TEMPLATE = 'USER_OTP_%d'
 

Защищенные члены

 setInitialDate (Type\DateTime $date)
 
 setDeactivateUntil ($date)
 
 setSkipMandatory ($isSkipped=true)
 
 getInitialTimestamp ()
 
 setUserId ($userId)
 
 setAttempts ($attemptsCount)
 
 setParams ($params)
 
 getDefaultIssuer ()
 
 generateLabel ($issuer=null)
 
 getMaxLoginAttempts ()
 
 getRememberLifetime ()
 
 getRememberIpMask ()
 
 canSkipByCookie ()
 
 getSkipCookieValue ()
 
 setSkipCookie ()
 
 isDbRecordExists ()
 
 getPolicy ()
 
 clearGlobalCache ()
 

Защищенные статические члены

static sendEvent (Otp $otp)
 

Защищенные данные

 $algorithmClass = null
 
 $regenerated = false
 
 $context = null
 
 $userId = null
 
 $userLogin = null
 
 $userGroupPolicy
 
 $active = null
 
 $userActive = null
 
 $secret = null
 
 $issuer = null
 
 $label = null
 
 $params = null
 
 $attempts = null
 
 $type = null
 
 $initialDate = null
 
 $skipMandatory = null
 
 $deactivateUntil = null
 

Статические защищенные данные

static $availableTypes = array(self::TYPE_HOTP, self::TYPE_TOTP)
 
static $typeMap
 

Подробное описание

См. определение в файле otp.php строка 19

Конструктор(ы)

◆ __construct()

__construct (   $algorithm = null)
Аргументы
string | null$algorithmClass of needed OtpAlgorithm.

См. определение в файле otp.php строка 65

Методы

◆ activate()

activate ( )

Activate user OTP OTP must be initialized (have secret, params, etc) before activate

Возвращает
$this
Исключения
OtpException

См. определение в файле otp.php строка 383

◆ canSkipByCookie()

canSkipByCookie ( )
protected

Check if user have valid cookie for skip OTP checking ("Remember OTP on this computer")

Возвращает
bool

См. определение в файле otp.php строка 990

◆ canSkipMandatory()

canSkipMandatory ( )

Check if current user can skip OTP mandatory using. It can skip if:

  • Otp already activated
  • User never login before
  • User not included to mandatory rights
  • The current date is included in the window initialization
Возвращает
bool

См. определение в файле otp.php строка 957

◆ canSkipMandatoryByRights()

canSkipMandatoryByRights ( )

Check if current user not included to mandatory rights

Возвращает
bool

См. определение в файле otp.php строка 975

◆ clearGlobalCache()

clearGlobalCache ( )
protected

Clear cache for this OTP in global scope

Возвращает
$this

См. определение в файле otp.php строка 1098

◆ deactivate()

deactivate (   $days = 0)

Deactivate user OTP for a needed number of days or forever

Аргументы
int$daysDays. 0 means "forever".
Возвращает
$this
Исключения
OtpException

См. определение в файле otp.php строка 403

◆ defer()

defer (   $days = 0)

Defer mandatory user OTP using for a needed number of days or forever

Аргументы
int$daysDays. 0 means "forever".
Возвращает
$this
Исключения
OtpException

См. определение в файле otp.php строка 433

◆ delete()

delete ( )

Delete OTP record from DB

Возвращает
$this

См. определение в файле otp.php строка 369

◆ generateLabel()

generateLabel (   $issuer = null)
protected

Generate label, based on current host, user login and issuer (if provided)

Аргументы
string | null$issuerIssuer.
Возвращает
string

См. определение в файле otp.php строка 900

◆ getAppSecret()

getAppSecret ( )

Return mobile application secret, using for manual device initialization

Возвращает
string

См. определение в файле otp.php строка 717

◆ getAttempts()

getAttempts ( )

Return verifying attempts count

Возвращает
int

См. определение в файле otp.php строка 661

◆ getAvailableTypes()

static getAvailableTypes ( )
static

Return available OtpAlgorithm types

Возвращает
array

См. определение в файле otp.php строка 1456

◆ getByType()

static getByType (   $type)
static

Return new instance with needed OtpAlgorithm type

Аргументы
string$typeType of OtpAlgorithm (see getAvailableTypes).
Исключения

Bitrix\Main\ArgumentOutOfRangeException

Возвращает
static New instance

См. определение в файле otp.php строка 128

◆ getByUser()

static getByUser (   $userId)
static

Return new instance for user provided by user ID

Аргументы
int$userIdUser ID.
Исключения
ArgumentOutOfRangeException
ArgumentTypeException
Возвращает
static New instance, if user does not use OTP - returning NullObject (see Otp::isActivated).

См. определение в файле otp.php строка 85

◆ getContext()

getContext ( )

Returns context of the current request.

Возвращает
\Bitrix\Main\Context

См. определение в файле otp.php строка 821

◆ getDeactivateUntil()

getDeactivateUntil ( )
Возвращает
Type\DateTime

См. определение в файле otp.php строка 528

◆ getDefaultIssuer()

getDefaultIssuer ( )
protected

Return default issuer

Возвращает
string

См. определение в файле otp.php строка 881

◆ getDefaultType()

static getDefaultType ( )
static

Return default OtpAlgorithm type

Возвращает
string

См. определение в файле otp.php строка 1446

◆ getDeferredParams()

static getDeferredParams ( )
static

Return deferred params (see verifyUser)

Возвращает
array|null

См. определение в файле otp.php строка 1322

◆ getHexSecret()

getHexSecret ( )

Return hex-encoded secret

Возвращает
string

См. определение в файле otp.php строка 705

◆ getInitialDate()

getInitialDate ( )

Returns OTP initialization date

Возвращает
Type\DateTime

См. определение в файле otp.php строка 507

◆ getInitialTimestamp()

getInitialTimestamp ( )
protected

Returns Unix timestamp of OTP initialization date

Возвращает
int

См. определение в файле otp.php строка 561

◆ getIssuer()

getIssuer ( )

Return issuer. If custom issuer not available - return default (see getDefaultIssuer).

Возвращает
string

См. определение в файле otp.php строка 769

◆ getLabel()

getLabel (   $issuer = null)

Return label for issuer (if provided) If custom label not available - generate default (see generateLabel)

Аргументы
string | null$issuerIssuer.
Возвращает
string

См. определение в файле otp.php строка 796

◆ getMandatoryRights()

static getMandatoryRights ( )
static

Return user rights who must use OTP in mandatory way

Возвращает
array

См. определение в файле otp.php строка 1415

◆ getMaxLoginAttempts()

getMaxLoginAttempts ( )
protected

Return maximum verifying attempts, based on security group policy

Возвращает
int

См. определение в файле otp.php строка 913

◆ getParams()

getParams ( )

Return user params (e.g. counter for HotpAlgorithm)

Возвращает
string

См. определение в файле otp.php строка 685

◆ getPolicy()

getPolicy ( )
protected

Return needed group security policy

Возвращает
Policy\RulesCollection

См. определение в файле otp.php строка 1083

◆ getProvisioningUri()

getProvisioningUri ( array  $opts = array())

Return Provision URI according to KeyUriFormat

array $opts Additional URI parameters, e.g. ['image' => 'http://example.com/my_logo.png'] . string

См. определение в файле otp.php строка 186

◆ getRememberIpMask()

getRememberIpMask ( )
protected

Return IP mask for checks remember value

Возвращает
string

См. определение в файле otp.php строка 939

◆ getRememberLifetime()

getRememberLifetime ( )
protected

Return how long (in sec)remember value are valid

Возвращает
int

См. определение в файле otp.php строка 926

◆ getSecret()

getSecret ( )

Return binary secret

Возвращает
string

См. определение в файле otp.php строка 695

◆ getSkipCookieValue()

getSkipCookieValue ( )
protected

Generate skip value for save in cookies Currently based on client IP and mask (see getRememberIpMask)

Возвращает
string

См. определение в файле otp.php строка 1021

◆ getSkipMandatoryDays()

static getSkipMandatoryDays ( )
static

Return initialization window (in days) for mandatory using checking

Возвращает
int

См. определение в файле otp.php строка 1373

◆ getSyncParameters()

getSyncParameters (   $inputA,
  $inputB 
)

Return synchronized user params for provided inputs

Аргументы
string$inputAFirst code.
string$inputBSecond code.
Исключения

Bitrix\Main\Security\OtpException

Возвращает
string

См. определение в файле otp.php строка 274

◆ getType()

getType ( )

Return used OtpAlgorithm type

Возвращает
string

См. определение в файле otp.php строка 162

◆ getTypesDescription()

static getTypesDescription ( )
static

Return available OtpAlgorithm types description

Возвращает
array

См. определение в файле otp.php строка 1466

◆ getUserId()

getUserId ( )

Return used User ID

Возвращает
int

См. определение в файле otp.php строка 588

◆ getUserLogin()

getUserLogin ( )

Return user login If custom login not available it will be fetched from DB

Возвращает
string

См. определение в файле otp.php строка 860

◆ isActivated()

isActivated ( )

Return is OTP activated or not

Возвращает
bool

См. определение в файле otp.php строка 611

◆ isAttemptsReached()

isAttemptsReached ( )

Check is verifying attempts reached according to group security policy May be used for show Captcha or what ever you want

Возвращает
bool

См. определение в файле otp.php строка 256

◆ isCaptchaRequired()

static isCaptchaRequired ( )
static

Return if user must provide captcha code before checking OTP password

Возвращает
bool

См. определение в файле otp.php строка 1306

◆ isDbRecordExists()

isDbRecordExists ( )
protected

Check if OTP record exists in DB

Возвращает
bool

См. определение в файле otp.php строка 1073

◆ isInitialized()

isInitialized ( )
Возвращает
bool

См. определение в файле otp.php строка 631

◆ isMandatorySkipped()

isMandatorySkipped ( )

Returns true if user can skip mandatory using

Возвращает
bool

См. определение в файле otp.php строка 551

◆ isMandatoryUsing()

static isMandatoryUsing ( )
static

Return is mandatory OTP using activated

Возвращает
bool

См. определение в файле otp.php строка 1394

◆ isOtpEnabled()

static isOtpEnabled ( )
static

Returns if OTP enabled

Возвращает
bool

См. определение в файле otp.php строка 1487

◆ isOtpRequired()

static isOtpRequired ( )
static

Returns true if user must provide password from device

Возвращает
bool

См. определение в файле otp.php строка 1277

◆ isOtpRequiredByMandatory()

static isOtpRequiredByMandatory ( )
static

Returns true if user doesn't use OTP, but it required and grace full period ends

Возвращает
bool

См. определение в файле otp.php строка 1287

◆ isRecoveryCodesEnabled()

static isRecoveryCodesEnabled ( )
static

Returns if "Recovery codes" are enabled

Возвращает
bool

См. определение в файле otp.php строка 1497

◆ isUserActive()

isUserActive ( )

См. определение в файле otp.php строка 623

◆ regenerate()

regenerate (   $newSecret = null)

Reinitialize OTP (generate new secret, set default algo, etc), must be called before connect new device

Аргументы
null$newSecretUsing custom secret.
Возвращает
$this

См. определение в файле otp.php строка 205

◆ save()

save ( )

Save all OTP data to DB

Исключения
OtpException
Возвращает
bool

См. определение в файле otp.php строка 324

◆ sendEvent()

static sendEvent ( Otp  $otp)
staticprotected

См. определение в файле otp.php строка 1250

◆ setActive()

setActive (   $isActive)

Set new activating state

Аргументы
bool$isActiveOtp is activated or not.
Возвращает
$this

См. определение в файле otp.php строка 599

◆ setAppSecret()

setAppSecret (   $value)

Set new mobile application secret

Аргументы
string$valueSecret.
Возвращает
$this

См. определение в файле otp.php строка 756

◆ setAttempts()

setAttempts (   $attemptsCount)
protected

Set new verifying attempts count

Аргументы
int$attemptsCountAttempts count.
Возвращает
$this

См. определение в файле otp.php строка 649

◆ setContext()

setContext ( \Bitrix\Main\Context  $context)

Set context of the current request.

Аргументы
\Bitrix\Main\Context$contextApplication context.
Возвращает
$this

См. определение в файле otp.php строка 835

◆ setDeactivateUntil()

setDeactivateUntil (   $date)
protected

Set datetime when user OTP must activated back

Аргументы
Type\DateTime | null$dateDatetime. "null" means never.
Возвращает
$this

См. определение в файле otp.php строка 518

◆ setDefaultType()

static setDefaultType (   $value)
static

Set default OtpAlgorithm type

Аргументы
string$valueOtpAlgorithm type (see getAvailableTypes).
Исключения
ArgumentOutOfRangeException
Возвращает
void

См. определение в файле otp.php строка 1432

◆ setDeferredParams()

static setDeferredParams (   $params)
static

Set or delete deferred params (see verifyUser)

Аргументы
array | null$paramsParams, null means deleting params from storage.
Возвращает
void

См. определение в файле otp.php строка 1339

◆ setHexSecret()

setHexSecret (   $hexValue)

Set new secret in hex-encoded representation

Аргументы
string$hexValueHex-encoded secret.
Возвращает
$this

См. определение в файле otp.php строка 743

◆ setInitialDate()

setInitialDate ( Type\DateTime  $date)
protected

Set new OTP initialization date

Аргументы
Type\DateTime$dateInitialization date.
Возвращает
$this

См. определение в файле otp.php строка 495

◆ setIssuer()

setIssuer (   $issuer)

Set custom issuer

Аргументы
string$issuerIssuer.
Возвращает
$this

См. определение в файле otp.php строка 783

◆ setLabel()

setLabel (   $label)

Set custom label

Аргументы
string$labelLabel.
Возвращает
$this

См. определение в файле otp.php строка 810

◆ setMandatoryRights()

static setMandatoryRights ( array  $rights)
static

Set user rights who must use OTP in mandatory way

Аргументы
array$rightsNeeded rights. E.g. ['G1'] for administrators.
Возвращает
void

См. определение в файле otp.php строка 1405

◆ setMandatoryUsing()

static setMandatoryUsing (   $isMandatory = true)
static

Activate or deactivate mandatory OTP using

Аргументы
bool$isMandatoryActive or not.
Возвращает
void

См. определение в файле otp.php строка 1384

◆ setParams()

setParams (   $params)
protected

Set new user params (e.g. counter for HotpAlgorithm)

См. также
getSyncParameters
Аргументы
string$paramsUser params.
Возвращает
$this

См. определение в файле otp.php строка 673

◆ setSecret()

setSecret (   $secret)

Set new secret

Аргументы
string$secretBinary secret.
Возвращает
$this

См. определение в файле otp.php строка 731

◆ setSkipCookie()

setSkipCookie ( )
protected

Store new value for skip OTP checking ("Remember OTP on this computer") in cookies

Возвращает
$this

@global \CMain $APPLICATION

См. определение в файле otp.php строка 1034

◆ setSkipMandatory()

setSkipMandatory (   $isSkipped = true)
protected

Set if user allowed to bypass OTP mandatory using while authorization

Аргументы
bool$isSkippedAllowed or not.
Возвращает
$this

См. определение в файле otp.php строка 539

◆ setSkipMandatoryDays()

static setSkipMandatoryDays (   $days = 2)
static

Set initialization window (in days) for mandatory using checking

Аргументы
int$daysDays of initialization window. "0" means immediately (on next user authorization).
Возвращает
void

См. определение в файле otp.php строка 1363

◆ setType()

setType (   $type)

Set new type of OtpAlgorithm

Аргументы
string$typeType of OtpAlgorithm (see getAvailableTypes).
Исключения
ArgumentOutOfRangeException
Возвращает
$this

См. определение в файле otp.php строка 146

◆ setUserActive()

setUserActive (   $isActive)

См. определение в файле otp.php строка 616

◆ setUserId()

setUserId (   $userId)
protected

Set new User ID

Аргументы
int$userIdUser ID.
Возвращает
$this

См. определение в файле otp.php строка 576

◆ setUserInfo()

setUserInfo ( array  $userInfo)

Set new user information Mostly used for initialization from DB Now support:

  • ACTIVE: bool, activating state (see setActive)
  • USER_ID: integer, User ID (see setUserId)
  • ATTEMPTS: integer, Attempts counter (see setAttempts)
  • SECRET: binary, User secret (see setSecret)
  • PARAMS: string, User params (see setParams and getSyncParameters)
  • INITIAL_DATE: Type\Date, OTP initial date (see setInitialDate)
Аргументы
array$userInfoSee above.
Возвращает
$this

См. определение в файле otp.php строка 468

◆ setUserLogin()

setUserLogin (   $login)

Set custom user login

Аргументы
string$loginLogin.
Возвращает
$this

См. определение в файле otp.php строка 847

◆ syncParameters()

syncParameters (   $inputA,
  $inputB = null 
)

Synchronize user params for provided inputs Must be called after regenerate and before save! If something went wrong - throw OtpException with valid description in message

Аргументы
string$inputAFirst code.
string | null$inputBSecond code.
Исключения
OtpException
Возвращает
$this

См. определение в файле otp.php строка 289

◆ verify()

verify (   $input,
  $updateParams = true 
)

Verify provided input

Аргументы
string$inputInput received from user.
bool$updateParamsUpdate or not user parameters in DB (e.g. counter for HotpAlgorithm).
Возвращает
bool True if input is valid.

См. определение в файле otp.php строка 232

◆ verifyUser()

static verifyUser ( array  $params)
static

Most complex method, can check everything:-) ToDo: describe after refactoring

Аргументы
array$paramsEvent parameters.
Возвращает
bool

См. определение в файле otp.php строка 1114

Данные класса

◆ $active

$active = null
protected

См. определение в файле otp.php строка 48

◆ $algorithmClass

$algorithmClass = null
protected

См. определение в файле otp.php строка 39

◆ $attempts

$attempts = null
protected

См. определение в файле otp.php строка 54

◆ $availableTypes

$availableTypes = array(self::TYPE_HOTP, self::TYPE_TOTP)
staticprotected

См. определение в файле otp.php строка 34

◆ $context

$context = null
protected

См. определение в файле otp.php строка 42

◆ $deactivateUntil

$deactivateUntil = null
protected

См. определение в файле otp.php строка 60

◆ $initialDate

$initialDate = null
protected

См. определение в файле otp.php строка 57

◆ $issuer

$issuer = null
protected

См. определение в файле otp.php строка 51

◆ $label

$label = null
protected

См. определение в файле otp.php строка 52

◆ $params

$params = null
protected

См. определение в файле otp.php строка 53

◆ $regenerated

$regenerated = false
protected

См. определение в файле otp.php строка 40

◆ $secret

$secret = null
protected

См. определение в файле otp.php строка 50

◆ $skipMandatory

$skipMandatory = null
protected

См. определение в файле otp.php строка 58

◆ $type

$type = null
protected

См. определение в файле otp.php строка 55

◆ $typeMap

$typeMap
staticprotected
Инициализатор
= array(
self::TYPE_HOTP => '\Bitrix\Main\Security\Mfa\HotpAlgorithm',
self::TYPE_TOTP => '\Bitrix\Main\Security\Mfa\TotpAlgorithm',
)

См. определение в файле otp.php строка 35

◆ $userActive

$userActive = null
protected

См. определение в файле otp.php строка 49

◆ $userGroupPolicy

$userGroupPolicy
protected

См. определение в файле otp.php строка 47

◆ $userId

$userId = null
protected

См. определение в файле otp.php строка 44

◆ $userLogin

$userLogin = null
protected

См. определение в файле otp.php строка 45

◆ REJECT_BY_CODE

const REJECT_BY_CODE = 'code'

См. определение в файле otp.php строка 29

◆ REJECT_BY_MANDATORY

const REJECT_BY_MANDATORY = 'mandatory'

См. определение в файле otp.php строка 30

◆ REJECTED_KEY

const REJECTED_KEY = 'OTP_REJECT_REASON'

См. определение в файле otp.php строка 28

◆ SECRET_LENGTH

const SECRET_LENGTH = 20

См. определение в файле otp.php строка 24

◆ SKIP_COOKIE

const SKIP_COOKIE = 'OTPH'

См. определение в файле otp.php строка 26

◆ TAGGED_CACHE_TEMPLATE

const TAGGED_CACHE_TEMPLATE = 'USER_OTP_%d'

См. определение в файле otp.php строка 32

◆ TYPE_DEFAULT

const TYPE_DEFAULT = self::TYPE_HOTP

См. определение в файле otp.php строка 23

◆ TYPE_HOTP

const TYPE_HOTP = 'hotp'

См. определение в файле otp.php строка 21

◆ TYPE_TOTP

const TYPE_TOTP = 'totp'

См. определение в файле otp.php строка 22