PHP Class Thruway\Authentication\AuthorizationManager

Inheritance: extends Thruway\Peer\Client, implements Thruway\Authentication\AuthorizationManagerInterface
Show file Open project: voryx/thruway

Public Methods

Method Description
__construct ( string $realm, null $loop = null )
addAuthorizationRule ( $args ) : string rules look like (JSON) { "role": "some_role", "action": "publish", "uri": "some.uri", "allow": true }
flushAuthorizationRules ( boolean $allowByDefault = false ) : string
getAuthorizationRules ( ) : Result
getSubscribedEvents ( ) : array Listen for Router events
getSubscribedRealmEvents ( ) : array
handleMessage ( MessageEvent $messageEvent )
handleNewRealm ( NewRealmEvent $newRealmEvent )
initModule ( Thruway\Peer\RouterInterface $router, React\EventLoop\LoopInterface $loop ) Gets called when the module is initialized in the router
isAuthorizedTo ( Session $session, Thruway\Message\ActionMessageInterface $actionMsg ) : boolean Check to see if an action is authorized on a specific uri given the context of the session attempting the action
isReady ( ) : boolean
isValidAction ( $action ) : boolean
isValidRuleUri ( $uri ) : boolean
onSessionStart ( ClientSession $session, Thruway\Transport\TransportInterface $transport )
removeAuthorizationRule ( $args )
setReady ( boolean $ready )
testAuthorization ( $args ) : boolean | mixed Arguments need to be [["role1", "role2"], "publish|subscribe|register|call", "my.uri"]

Private Methods

Method Description
getRuleFromArgs ( $args ) : stdClass | boolean
isAuthorizedByRolesActionAndUri ( $rolesToCheck, $action, $uri ) : boolean | mixed

Method Details

__construct() public method

public __construct ( string $realm, null $loop = null )
$realm string
$loop null

addAuthorizationRule() public method

Should be $args[0]
public addAuthorizationRule ( $args ) : string
$args
return string

flushAuthorizationRules() public method

public flushAuthorizationRules ( boolean $allowByDefault = false ) : string
$allowByDefault boolean
return string

getAuthorizationRules() public method

public getAuthorizationRules ( ) : Result
return Thruway\Result

getSubscribedEvents() public static method

Listen for Router events
public static getSubscribedEvents ( ) : array
return array

getSubscribedRealmEvents() public method

public getSubscribedRealmEvents ( ) : array
return array

handleMessage() public method

public handleMessage ( MessageEvent $messageEvent )
$messageEvent Thruway\Event\MessageEvent

handleNewRealm() public method

public handleNewRealm ( NewRealmEvent $newRealmEvent )
$newRealmEvent Thruway\Event\NewRealmEvent

initModule() public method

Gets called when the module is initialized in the router
public initModule ( Thruway\Peer\RouterInterface $router, React\EventLoop\LoopInterface $loop )
$router Thruway\Peer\RouterInterface
$loop React\EventLoop\LoopInterface

isAuthorizedTo() public method

actionMsg should be an instance of: register, call, subscribe, or publish messages
public isAuthorizedTo ( Session $session, Thruway\Message\ActionMessageInterface $actionMsg ) : boolean
$session Thruway\Session
$actionMsg Thruway\Message\ActionMessageInterface
return boolean

isReady() public method

public isReady ( ) : boolean
return boolean

isValidAction() public static method

public static isValidAction ( $action ) : boolean
$action
return boolean

isValidRuleUri() public static method

public static isValidRuleUri ( $uri ) : boolean
$uri
return boolean

onSessionStart() public method

public onSessionStart ( ClientSession $session, Thruway\Transport\TransportInterface $transport )
$session Thruway\ClientSession
$transport Thruway\Transport\TransportInterface

removeAuthorizationRule() public method

public removeAuthorizationRule ( $args )
$args

setReady() public method

public setReady ( boolean $ready )
$ready boolean

testAuthorization() public method

Arguments need to be [["role1", "role2"], "publish|subscribe|register|call", "my.uri"]
public testAuthorization ( $args ) : boolean | mixed
$args
return boolean | mixed