PHP 클래스 Psecio\Gatekeeper\Gatekeeper

파일 보기 프로젝트 열기: psecio/gatekeeper 1 사용 예제들

공개 메소드들

메소드 설명
__callStatic ( string $name, arrya $args ) : mixed Handle undefined static function calls
authenticate ( array $credentials, boolean $remember = false ) : boolean Authenticate a user given the username/password credentials
buildDataSource ( array $config, array $result ) : DataSource Build a datasource object
buildModel ( string $action = 'find', string $name, array $args ) : object Build the model instance with data given
checkRememberMe ( ) : boolean | Psecio\Gatekeeper\UserModel Check the "Remember Me" token information (if it exists)
clearRestrictions ( ) Clear out the current restrictions
createPolicy ( array $policy ) : boolean Allow for the creation of a policy as a callback too
disableThrottle ( ) Disable the throttling
enableThrottle ( ) Enable the throttling feature
evaluatePolicy ( string $name, mixed $data ) : boolean Evaluate the policy (found by name) against the data provided
getConfig ( string $index = null ) : mixed Get the current configuration information If an index is given, it tries to find it. If found, returns just that value. If not, returns null. Otherwise returns all config values
getDatasource ( ) : DataSource Get the current datasource
getLastError ( ) : string Get the last error message from the current datasource
getLogger ( ) : Psr\Log\LoggerInterface Get the current logger instance
getRestrictions ( ) : array Get the current list of restrictions
getUserThrottle ( integer $userId ) : Psecio\Gatekeeper\ThrottleModel Get the user throttle information If not found, makes a new one
hash_equals ( string $hash1, string $hash2 ) : boolean Safer way to evaluate if hashes equal
init ( string $envPath = null, array $config = [], DataSource $datasource = null, $logger = null ) Initialize the Gatekeeper instance, set up environment file and PDO connection
loadConfig ( array $config, string $envPath = null ) : array Get the configuration either from the config given or .env path
modelFactory ( string $type, array $data = [] ) : object Create and setup a new model instance
register ( array $userData ) : boolean Register a new user
rememberMe ( Psecio\Gatekeeper\UserModel | string $user, array $config = [] ) : boolean Enable and set up the "Remember Me" cookie token handling for the given user
restrict ( string $type, array $config ) Create a restriction and add it to be evaluated
setConfig ( array $config ) Set the current configuration options
setDatasource ( DataSource $ds ) Set the current data source to the one given
setLogger ( Psr\Log\LoggerInterface $logger = null ) Set the current logger interface If the logger value is null, a Monolog instance will be created
throttleStatus ( ) : boolean Return the enabled/disabled status of the throttling

보호된 메소드들

메소드 설명
loadDotEnv ( string $envPath ) : array | boolean Load the variables using the .env handling

메소드 상세

__callStatic() 공개 정적인 메소드

Handle undefined static function calls
public static __callStatic ( string $name, arrya $args ) : mixed
$name string Function name
$args arrya Arguments set
리턴 mixed Boolean false if function not matched, otherwise Model instance

authenticate() 공개 정적인 메소드

Authenticate a user given the username/password credentials
public static authenticate ( array $credentials, boolean $remember = false ) : boolean
$credentials array Credential information (must include "username" and "password")
$remember boolean Flag to activate the "remember me" functionality
리턴 boolean Pass/fail of authentication

buildDataSource() 공개 정적인 메소드

Build a datasource object
public static buildDataSource ( array $config, array $result ) : DataSource
$config array Configuration settings
$result array Environment data
리턴 DataSource instance

buildModel() 공개 정적인 메소드

Build the model instance with data given
public static buildModel ( string $action = 'find', string $name, array $args ) : object
$action string Action called (ex: "delete" or "create")
$name string Function nname
$args array Arguments set
리턴 object Model instance

checkRememberMe() 공개 정적인 메소드

Check the "Remember Me" token information (if it exists)
public static checkRememberMe ( ) : boolean | Psecio\Gatekeeper\UserModel
리턴 boolean | Psecio\Gatekeeper\UserModel Success/fail of token validation or User model instance

clearRestrictions() 공개 정적인 메소드

Clear out the current restrictions
public static clearRestrictions ( )

createPolicy() 공개 정적인 메소드

Allow for the creation of a policy as a callback too
public static createPolicy ( array $policy ) : boolean
$policy array Policy settings
리턴 boolean Success/fail of policy creation

disableThrottle() 공개 정적인 메소드

Disable the throttling
public static disableThrottle ( )

enableThrottle() 공개 정적인 메소드

Enable the throttling feature
public static enableThrottle ( )

evaluatePolicy() 공개 정적인 메소드

Evaluate the policy (found by name) against the data provided
public static evaluatePolicy ( string $name, mixed $data ) : boolean
$name string Name of the policy
$data mixed Data to use in evaluation (single object or array)
리턴 boolean Pass/fail status of evaluation

getConfig() 공개 정적인 메소드

Get the current configuration information If an index is given, it tries to find it. If found, returns just that value. If not, returns null. Otherwise returns all config values
public static getConfig ( string $index = null ) : mixed
$index string Index to locate [optional]
리턴 mixed Single value if index found, otherwise array of all

getDatasource() 공개 정적인 메소드

Get the current datasource
public static getDatasource ( ) : DataSource
리턴 DataSource instance

getLastError() 공개 정적인 메소드

Get the last error message from the current datasource
public static getLastError ( ) : string
리턴 string Error message (or empty string)

getLogger() 공개 정적인 메소드

Get the current logger instance
public static getLogger ( ) : Psr\Log\LoggerInterface
리턴 Psr\Log\LoggerInterface object

getRestrictions() 공개 정적인 메소드

Get the current list of restrictions
public static getRestrictions ( ) : array
리턴 array Set of restrictions

getUserThrottle() 공개 정적인 메소드

Get the user throttle information If not found, makes a new one
public static getUserThrottle ( integer $userId ) : Psecio\Gatekeeper\ThrottleModel
$userId integer User ID
리턴 Psecio\Gatekeeper\ThrottleModel instance

hash_equals() 공개 정적인 메소드

Safer way to evaluate if hashes equal
public static hash_equals ( string $hash1, string $hash2 ) : boolean
$hash1 string Hash #1
$hash2 string Hash #1
리턴 boolean Pass/fail on hash equality

init() 공개 정적인 메소드

Initialize the Gatekeeper instance, set up environment file and PDO connection
public static init ( string $envPath = null, array $config = [], DataSource $datasource = null, $logger = null )
$envPath string Environment file path (defaults to CWD)
$config array Configuration settings [optional]
$datasource DataSource Custom datasource provider

loadConfig() 공개 정적인 메소드

Get the configuration either from the config given or .env path
public static loadConfig ( array $config, string $envPath = null ) : array
$config array Configuration values
$envPath string Path to .env file
리턴 array Set of configuration values

loadDotEnv() 보호된 정적인 메소드

Load the variables using the .env handling
protected static loadDotEnv ( string $envPath ) : array | boolean
$envPath string Path to the .env file
리턴 array | boolean Array of data if found, false if load fails

modelFactory() 공개 정적인 메소드

Create and setup a new model instance
public static modelFactory ( string $type, array $data = [] ) : object
$type string Model class name
$data array
리턴 object Model instance

register() 공개 정적인 메소드

Register a new user
public static register ( array $userData ) : boolean
$userData array User data
리턴 boolean Success/fail of user create

rememberMe() 공개 정적인 메소드

Enable and set up the "Remember Me" cookie token handling for the given user
public static rememberMe ( Psecio\Gatekeeper\UserModel | string $user, array $config = [] ) : boolean
$user Psecio\Gatekeeper\UserModel | string User model instance
$config array Set of configuration settings
리턴 boolean Success/fail of sesssion setup

restrict() 공개 정적인 메소드

Create a restriction and add it to be evaluated
public static restrict ( string $type, array $config )
$type string Restriction type
$config array Restriction configuration

setConfig() 공개 정적인 메소드

Set the current configuration options
public static setConfig ( array $config )
$config array Set of configuration settings

setDatasource() 공개 정적인 메소드

Set the current data source to the one given
public static setDatasource ( DataSource $ds )
$ds DataSource Data source instance

setLogger() 공개 정적인 메소드

Set the current logger interface If the logger value is null, a Monolog instance will be created
public static setLogger ( Psr\Log\LoggerInterface $logger = null )
$logger Psr\Log\LoggerInterface PSR logger or null

throttleStatus() 공개 정적인 메소드

Return the enabled/disabled status of the throttling
public static throttleStatus ( ) : boolean
리턴 boolean Throttle status