PHP Class Psecio\PropAuth\Enforcer

Show file Open project: psecio/propauth Class Usage Examples

Public Methods

Method Description
__construct ( PolicySet $policySet = null ) Init the object, possibly with an optional policy set
allows ( string $policyName, object $subject, array $addl = [] ) : boolean Locate a policy by key name and determine if the subject is allowed by matching against its properties
denies ( string $policyName, object $subject, array $addl = [] ) : boolean Locate a policy by name and evaluate if the subject is denied by matching against its properties
evaluate ( object $subject, Policy $policy, array $addl = [] ) : boolean Given a subject and a policy, evaluate the pass/fail result of the matching
executeTests ( array $tests, string $type, string $propertyValue, array $addl ) : boolean Execute the tests on the policy to ensure they match/pass
getPropertyValue ( string $type, object $subject ) : mixed Type a few options to get the property value for evaluation
instance ( PolicySet $policySet = null ) : Enforcer Static method to get a new instance of the Enforcer object
setPolicySet ( PolicySet $policySet ) : Enforcer Set the current policy set (overrides, not appends)

Method Details

__construct() public method

Init the object, possibly with an optional policy set
public __construct ( PolicySet $policySet = null )
$policySet PolicySet Set of Policy instances [optional]

allows() public method

Locate a policy by key name and determine if the subject is allowed by matching against its properties
public allows ( string $policyName, object $subject, array $addl = [] ) : boolean
$policyName string Policy name to evaluate
$subject object Subject to evaluate against
$addl array
return boolean Pass/fail result of evaluation

denies() public method

Locate a policy by name and evaluate if the subject is denied by matching against its properties
public denies ( string $policyName, object $subject, array $addl = [] ) : boolean
$policyName string Policy key name
$subject object Subject to evluate against
$addl array
return boolean Pass/fail of evluation

evaluate() public method

Given a subject and a policy, evaluate the pass/fail result of the matching
public evaluate ( object $subject, Policy $policy, array $addl = [] ) : boolean
$subject object Subject to match against
$policy Policy Policy to evaluate
$addl array
return boolean Pass/fail status of evaluation

executeTests() public method

Execute the tests on the policy to ensure they match/pass
public executeTests ( array $tests, string $type, string $propertyValue, array $addl ) : boolean
$tests array A set of Check instances to evaluate
$type string Type of tests to evaluate with
$propertyValue string Value to evaluate against
$addl array Additional values to pass through to the test
return boolean Pass/fail status of the evaluation (if exception not thrown)

getPropertyValue() public method

Type a few options to get the property value for evaluation
public getPropertyValue ( string $type, object $subject ) : mixed
$type string Type of check being performed
$subject object Object to get the property value from
return mixed Either the found property value or null if not found

instance() public static method

Static method to get a new instance of the Enforcer object
public static instance ( PolicySet $policySet = null ) : Enforcer
$policySet PolicySet Set of policies [optional]
return Enforcer instance

setPolicySet() public method

Set the current policy set (overrides, not appends)
public setPolicySet ( PolicySet $policySet ) : Enforcer
$policySet PolicySet Set of Policy objects
return Enforcer instance