Thruway\Authentication\AuthenticationManager::registerAuthMethod PHP Метод

registerAuthMethod() публичный Метод

This is called via a WAMP RPC URI. It is registered as thruway.auth.registermethod it takes arguments in an array - ["methodName", ["realm1", "realm2", "*"],
public registerAuthMethod ( array $args, array $kwargs, array $details ) : array
$args array
$kwargs array
$details array
Результат array
    public function registerAuthMethod(array $args, $kwargs, $details)
    {
        // TODO: should return different error
        if (!is_array($args)) {
            return ["Received non-array arguments in registerAuthMethod"];
        }
        if (count($args) < 2) {
            return ["Not enough arguments sent to registerAuthMethod"];
        }
        $authMethod = $args[0];
        $methodInfo = $args[1];
        $authRealms = $args[2];
        // TODO: validate this stuff
        if (isset($this->authMethods[$authMethod])) {
            // error - there is alreay a registered authMethod of this name
            return ["ERROR", "Method registration already exists"];
        }
        if (!isset($methodInfo->onhello)) {
            return ["ERROR", "Authentication provider must provide \"onhello\" handler"];
        }
        if (!isset($methodInfo->onauthenticate)) {
            return ["ERROR", "Authentication provider must provide \"onauthenticate\" handler"];
        }
        if (!isset($details->caller)) {
            return ["ERROR", "Invocation must provide \"caller\" detail on registration"];
        }
        $this->authMethods[$authMethod] = ['authMethod' => $authMethod, 'handlers' => $methodInfo, 'auth_realms' => $authRealms, 'session_id' => $details->caller];
        return ["SUCCESS"];
    }