PHP Class Pop\Auth\Auth

Author: Nick Sagona, III ([email protected])
显示文件 Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$adapter mixed Auth adapter object
$attempts integer Current number of login attempts
$encryption integer Encryption method to use
$encryptionOptions array 'salt' // Custom Salt 'secret' // Secret pepper 'cost' // Bcrypt cost 'prefix' // Bcrypt prefix 'rounds' // Sha rounds 'cipher' // Mcrypt cipher 'mode' // Mcrypt cipher 'source' // Mcrypt source
$ip string Current IP address
$isValid boolean User validation result from authentication
$result integer Authentication result
$subnet array Current subnet
$validators array Array of validator objects

Public Methods

Method Description
__construct ( Pop\Auth\Adapter\AdapterInterface $adapter, integer $encryption, array $options = [] ) : Auth Constructor
authenticate ( string $username, string $password ) : integer Method to authenticate a user
factory ( Pop\Auth\Adapter\AdapterInterface $adapter, integer $encryption ) : Auth Static method to instantiate the auth object and return itself to facilitate chaining methods together.
getAttempts ( ) : integer Method to get the current number of login attempts
getEncryption ( ) : integer Method to get the encryption
getEncryptionOptions ( ) : array Method to get the encryption options
getResult ( ) : integer Method to get the authentication result
getResultMessage ( ) : string Method to get the authentication result message
getUser ( ) : array Method to get the user data array from the adapter
getValidator ( string $name ) : mixed Method to get a validator
isValid ( ) : boolean Method to determine if the user is valid
setAllowedIps ( string | array $ips = null ) : Auth Method to set the allowed IP addresses
setAllowedSubnets ( string | array $subnets = null ) : Auth Method to set the allowed subnets
setAttemptLimit ( integer $attempts ) : Auth Method to set the number of attempts allowed
setAttempts ( integer $attempts ) : Auth Method to set the number of attempts allowed
setBlockedIps ( string | array $ips = null ) : Auth Method to set the block IP addresses
setBlockedSubnets ( string | array $subnets = null ) : Auth Method to set the block subnets
setEncryption ( integer $encryption ) : Auth Method to set the encryption
setEncryptionOptions ( array $options = [] ) : Auth Method to set the encryption options

Protected Methods

Method Description
filterIps ( string | array $ips ) : array Method to filter the ip addresses to confirm their validity
filterSubnets ( string | array $subnets ) : array Method to filter the subnets to confirm their validity
processValidators ( ) : void Method to process the validators

Method Details

__construct() public method

Instantiate the auth object
public __construct ( Pop\Auth\Adapter\AdapterInterface $adapter, integer $encryption, array $options = [] ) : Auth
$adapter Pop\Auth\Adapter\AdapterInterface
$encryption integer
$options array
return Auth

authenticate() public method

Method to authenticate a user
public authenticate ( string $username, string $password ) : integer
$username string
$password string
return integer

factory() public static method

Static method to instantiate the auth object and return itself to facilitate chaining methods together.
public static factory ( Pop\Auth\Adapter\AdapterInterface $adapter, integer $encryption ) : Auth
$adapter Pop\Auth\Adapter\AdapterInterface
$encryption integer
return Auth

filterIps() protected method

Method to filter the ip addresses to confirm their validity
protected filterIps ( string | array $ips ) : array
$ips string | array
return array

filterSubnets() protected method

Method to filter the subnets to confirm their validity
protected filterSubnets ( string | array $subnets ) : array
$subnets string | array
return array

getAttempts() public method

Method to get the current number of login attempts
public getAttempts ( ) : integer
return integer

getEncryption() public method

Method to get the encryption
public getEncryption ( ) : integer
return integer

getEncryptionOptions() public method

Method to get the encryption options
public getEncryptionOptions ( ) : array
return array

getResult() public method

Method to get the authentication result
public getResult ( ) : integer
return integer

getResultMessage() public method

Method to get the authentication result message
public getResultMessage ( ) : string
return string

getUser() public method

Method to get the user data array from the adapter
public getUser ( ) : array
return array

getValidator() public method

Method to get a validator
public getValidator ( string $name ) : mixed
$name string
return mixed

isValid() public method

Method to determine if the user is valid
public isValid ( ) : boolean
return boolean

processValidators() protected method

Method to process the validators
protected processValidators ( ) : void
return void

setAllowedIps() public method

Method to set the allowed IP addresses
public setAllowedIps ( string | array $ips = null ) : Auth
$ips string | array
return Auth

setAllowedSubnets() public method

Method to set the allowed subnets
public setAllowedSubnets ( string | array $subnets = null ) : Auth
$subnets string | array
return Auth

setAttemptLimit() public method

Method to set the number of attempts allowed
public setAttemptLimit ( integer $attempts ) : Auth
$attempts integer
return Auth

setAttempts() public method

Method to set the number of attempts allowed
public setAttempts ( integer $attempts ) : Auth
$attempts integer
return Auth

setBlockedIps() public method

Method to set the block IP addresses
public setBlockedIps ( string | array $ips = null ) : Auth
$ips string | array
return Auth

setBlockedSubnets() public method

Method to set the block subnets
public setBlockedSubnets ( string | array $subnets = null ) : Auth
$subnets string | array
return Auth

setEncryption() public method

Method to set the encryption
public setEncryption ( integer $encryption ) : Auth
$encryption integer
return Auth

setEncryptionOptions() public method

Method to set the encryption options
public setEncryptionOptions ( array $options = [] ) : Auth
$options array
return Auth

Property Details

$adapter protected_oe property

Auth adapter object
protected mixed $adapter
return mixed

$attempts protected_oe property

Current number of login attempts
protected int $attempts
return integer

$encryption protected_oe property

Encryption method to use
protected int $encryption
return integer

$encryptionOptions protected_oe property

'salt' // Custom Salt 'secret' // Secret pepper 'cost' // Bcrypt cost 'prefix' // Bcrypt prefix 'rounds' // Sha rounds 'cipher' // Mcrypt cipher 'mode' // Mcrypt cipher 'source' // Mcrypt source
protected array $encryptionOptions
return array

$ip protected_oe property

Current IP address
protected string $ip
return string

$isValid protected_oe property

User validation result from authentication
protected bool $isValid
return boolean

$result protected_oe property

Authentication result
protected int $result
return integer

$subnet protected_oe property

Current subnet
protected array $subnet
return array

$validators protected_oe property

Array of validator objects
protected array $validators
return array