Thruway\Authentication\WampCraAuthProvider::processHello PHP Метод

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

The session information is an associative array that contains the sessionId and realm
public processHello ( array $args ) : array
$args array
Результат array
    public function processHello(array $args)
    {
        $helloMsg = array_shift($args);
        $sessionInfo = array_shift($args);
        if (!is_array($helloMsg)) {
            return ["ERROR"];
        }
        if (!is_object($sessionInfo)) {
            return ["ERROR"];
        }
        $helloMsg = Message::createMessageFromArray($helloMsg);
        if (!$helloMsg instanceof HelloMessage || !$sessionInfo || !isset($helloMsg->getDetails()->authid) || !$this->getUserDb() instanceof WampCraUserDbInterface) {
            return ["ERROR"];
        }
        $authid = $helloMsg->getDetails()->authid;
        $user = $this->getUserDb()->get($authid);
        if (!$user) {
            return ["FAILURE"];
        }
        // create a challenge
        $nonce = bin2hex(openssl_random_pseudo_bytes(22));
        $authRole = "user";
        $authMethod = "wampcra";
        $authProvider = "userdb";
        $now = new \DateTime();
        $timeStamp = $now->format($now::ISO8601);
        if (!isset($sessionInfo->sessionId)) {
            return ["ERROR"];
        }
        $sessionId = $sessionInfo->sessionId;
        $challenge = ["authid" => $authid, "authrole" => $authRole, "authprovider" => $authProvider, "authmethod" => $authMethod, "nonce" => $nonce, "timestamp" => $timeStamp, "session" => $sessionId];
        $serializedChallenge = json_encode($challenge);
        $challengeDetails = ["challenge" => $serializedChallenge, "challenge_method" => $this->getMethodName()];
        if ($user['salt'] !== null) {
            // we are using salty password
            $saltInfo = ["salt" => $user['salt'], "keylen" => 32, "iterations" => 1000];
            $challengeDetails = array_merge($challengeDetails, $saltInfo);
        }
        return ["CHALLENGE", (object) $challengeDetails];
    }