PHP Class Webiny\Component\Security\Token\AbstractTokenStorage

Every token storage class must extend this class.
Inheritance: implements Webiny\Component\Security\Token\TokenStorageInterface, use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\Crypt\CryptTrait, use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: Webiny/Framework Class Usage Examples

Protected Properties

Property Type Description
$crypt Name of the crypt service.
$securityKey string Security key used for encrypting the token data.
$tokenName string Name of the token.
$tokenRememberMe boolean Should token be remembered

Public Methods

Method Description
decryptUserData ( string $tokenData ) : TokenData | boolean Decrypts the provided $tokenData, unserializes the string, creates an instance of TokenData and validates it.
encryptUserData ( AbstractUser $user ) : string Stores user data into an array, encrypts it and returns the encrypted string.
getCrypt ( ) : Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface Returns the crypt driver instance.
getEncryptionKey ( ) : string Uses the current key, user session id and browser user agent, to form a new key.
getTokenName ( ) : string Get token name.
setCrypt ( Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface $crypt ) Sets crypt driver instance.
setSecurityKey ( string $securityKey ) Sets the security key that will be used for encryption of token data.
setTokenName ( string $tokenName ) This function provides the token name to the storage.
setTokenRememberMe ( boolean $rememberMe ) This function provides the token 'remember me' flag to the storage.

Method Details

decryptUserData() public method

If TokenData is valid, its instance is returned, otherwise false is returned.
public decryptUserData ( string $tokenData ) : TokenData | boolean
$tokenData string Encrypted data.
return TokenData | boolean

encryptUserData() public method

Stores user data into an array, encrypts it and returns the encrypted string.
public encryptUserData ( AbstractUser $user ) : string
$user Webiny\Component\Security\User\AbstractUser Instance of AbstractUser class that holds the pre-filled object from user provider.
return string

getCrypt() public method

Returns the crypt driver instance.
public getCrypt ( ) : Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface
return Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface

getEncryptionKey() public method

The new key is then unique to that user, and is used for encryption/decryption process.
public getEncryptionKey ( ) : string
return string

getTokenName() public method

Get token name.
public getTokenName ( ) : string
return string Token name.

setCrypt() public method

Sets crypt driver instance.
public setCrypt ( Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface $crypt )
$crypt Webiny\Component\Security\Token\CryptDrivers\CryptDriverInterface Name of the crypt service.

setSecurityKey() public method

Sets the security key that will be used for encryption of token data.
public setSecurityKey ( string $securityKey )
$securityKey string Must have 16/32/64 chars.

setTokenName() public method

This function provides the token name to the storage.
public setTokenName ( string $tokenName )
$tokenName string Token name.

setTokenRememberMe() public method

This function provides the token 'remember me' flag to the storage.
public setTokenRememberMe ( boolean $rememberMe )
$rememberMe boolean Token rememberme.

Property Details

$crypt protected property

Name of the crypt service.
protected $crypt

$securityKey protected property

Security key used for encrypting the token data.
protected string $securityKey
return string

$tokenName protected property

Name of the token.
protected string $tokenName
return string

$tokenRememberMe protected property

Should token be remembered
protected bool $tokenRememberMe
return boolean