PHP Класс Airship\Engine\Security\Authentication

Airship gear: Authentication Covers both short-term authentication (current browsing session) and optional long-term authentication (i.e. "remember me" cookies).
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$db Airship\Engine\Contract\DBInterface
$dummyHash string
$tableConfig array $this->tableConfig contains all of the selectors (table/column names) used in the internal queries. This is useful if you need to change the queries in a Gear without rewriting them.

Открытые методы

Метод Описание
__construct ( EncryptionKey $key, Airship\Engine\Contract\DBInterface $db = null ) Authentication constructor.
createAuthToken ( integer $userId ) : string Create, store, and return a token for long-term authentication
createHash ( HiddenString $password ) : string Generate a hash of a password
login ( string $username, HiddenString $password ) : boolean | integer Verifies that the password is valid for a given user account. Returns false whether or not the user name is valid and attempts to minimize leaking that information through timing side-channels.
loginByToken ( string $token = '' ) : integer Authenticate a user by a long-term authentication token (e.g. a cookie).
migrateImportedHash ( HiddenString $password, HiddenString $passwordHash, array $userData = [] ) : boolean Attempt to login against a migrated hash. If successful, replace the existing password hash with an encrypted hash of the original password.
rotateToken ( string $token, integer $userId ) : mixed Replace the existing long-term authentication cookie
setDatabase ( Airship\Engine\Contract\DBInterface $db ) : self Sets the database handler.
setDatabaseByKey ( string $dbIndex = '' ) : self Set the database of this authentication library to match this
setLongTermSelectorField ( string $field ) : self Sets the column name used to reference the "selector" component of the long-term authentication token.
setLongTermValidatorField ( string $field ) : self Sets the column name used to reference the "validator" component of the long-term authentication token.
setPasswordField ( string $field ) : self Sets the column name used to reference the password hash stored in the database, for SQL queries.
setTable ( string $table ) : self Change the table used for
setUserIdField ( string $field ) : self Sets the column name used to reference the primary key (userid)
setUsernameField ( string $field ) : self Sets the column name used to reference the user selector, for SQL queries.

Защищенные методы

Метод Описание
registerMigrations ( ) Overloadable.

Описание методов

__construct() публичный Метод

Authentication constructor.
public __construct ( EncryptionKey $key, Airship\Engine\Contract\DBInterface $db = null )
$key EncryptionKey
$db Airship\Engine\Contract\DBInterface

createAuthToken() публичный Метод

Create, store, and return a token for long-term authentication
public createAuthToken ( integer $userId ) : string
$userId integer
Результат string (to store in a cookie, for example)

createHash() публичный Метод

Generate a hash of a password
public createHash ( HiddenString $password ) : string
$password HiddenString
Результат string

login() публичный Метод

Verifies that the password is valid for a given user account. Returns false whether or not the user name is valid and attempts to minimize leaking that information through timing side-channels.
public login ( string $username, HiddenString $password ) : boolean | integer
$username string
$password HiddenString
Результат boolean | integer

loginByToken() публичный Метод

Authenticate a user by a long-term authentication token (e.g. a cookie).
public loginByToken ( string $token = '' ) : integer
$token string
Результат integer int

migrateImportedHash() публичный Метод

Attempt to login against a migrated hash. If successful, replace the existing password hash with an encrypted hash of the original password.
public migrateImportedHash ( HiddenString $password, HiddenString $passwordHash, array $userData = [] ) : boolean
$password HiddenString
$passwordHash HiddenString
$userData array
Результат boolean

registerMigrations() защищенный Метод

Overloadable.
protected registerMigrations ( )

rotateToken() публичный Метод

Replace the existing long-term authentication cookie
public rotateToken ( string $token, integer $userId ) : mixed
$token string
$userId integer
Результат mixed

setDatabase() публичный Метод

Sets the database handler.
public setDatabase ( Airship\Engine\Contract\DBInterface $db ) : self
$db Airship\Engine\Contract\DBInterface
Результат self ($this)

setDatabaseByKey() публичный Метод

Set the database of this authentication library to match this
public setDatabaseByKey ( string $dbIndex = '' ) : self
$dbIndex string
Результат self ($this)

setLongTermSelectorField() публичный Метод

Sets the column name used to reference the "selector" component of the long-term authentication token.
public setLongTermSelectorField ( string $field ) : self
$field string
Результат self ($this)

setLongTermValidatorField() публичный Метод

Sets the column name used to reference the "validator" component of the long-term authentication token.
public setLongTermValidatorField ( string $field ) : self
$field string
Результат self ($this)

setPasswordField() публичный Метод

Sets the column name used to reference the password hash stored in the database, for SQL queries.
public setPasswordField ( string $field ) : self
$field string
Результат self ($this)

setTable() публичный Метод

Change the table used for
public setTable ( string $table ) : self
$table string
Результат self ($this)

setUserIdField() публичный Метод

Sets the column name used to reference the primary key (userid)
public setUserIdField ( string $field ) : self
$field string
Результат self ($this)

setUsernameField() публичный Метод

Sets the column name used to reference the user selector, for SQL queries.
public setUsernameField ( string $field ) : self
$field string
Результат self ($this)

Описание свойств

$db защищенное свойство

protected DBInterface,Airship\Engine\Contract $db
Результат Airship\Engine\Contract\DBInterface

$dummyHash защищенное свойство

protected string $dummyHash
Результат string

$tableConfig защищенное свойство

$this->tableConfig contains all of the selectors (table/column names) used in the internal queries. This is useful if you need to change the queries in a Gear without rewriting them.
protected array $tableConfig
Результат array