@absolunet/ioc2.1.0

View on GitHub

Gate

Gate service that allows to register policies and test those policies before executing command or anything that needs security checks.

Extends

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['app'].

Methods

can(gate)

Source:
Determine if the user is authorized to get through the given gates.
Parameters:
Name Type Description
gate string | Array.<string> Gate to validate through registered policies.
Returns:
Indicates that the policies passed.
Type
boolean

policy(policy, handler)

Source:
Register policy.
Parameters:
Name Type Description
policy string The policy name.
handler function The policy handler.

register(policy)

Source:
Register policy class.
Parameters:
Name Type Description
policy ioc.security.Policy The policy class.

resolve(gate)

Source:
Resolve policy handlers by name.
Parameters:
Name Type Description
gate string The gate to resolve.
Returns:
The resolved gate name, parametres and policies.
Type
Object

getGateName(gate)

Source:
Get the gate name, without arguments.
Parameters:
Name Type Description
gate string The gate.
Returns:
The gate name.
Type
string

getGateParameters(gate)

Source:
Get gate arguments from string call.
Parameters:
Name Type Description
gate string The gate.
Returns:
The list of parameters.
Type
Array.<string>

getPolicyConcrete(policy)

Source:
Get policy handler instance, either a closure or a policy class instance.
Parameters:
Name Type Description
policy * The policy or policy class.
Returns:
The policy callable function or class instance.
Type
function | Policy

handlePolicy(policy, parameters)

Source:
Execute policy handling, either from a closure or a class instance.
Parameters:
Name Type Description
policy function The policy callable function or class instance.
parameters Array.<string> The list of parameters.
Returns:
Indicates if the given policy passes with the given parameters.
Type
boolean