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

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

Process authenticate
public processAuthenticate ( mixed $signature, mixed $extra = null ) : array
$signature mixed
$extra mixed
Результат array
    public function processAuthenticate($signature, $extra = null)
    {
        $challenge = $this->getChallengeFromExtra($extra);
        if (!$challenge || !isset($challenge->authid) || !$this->getUserDb() instanceof WampCraUserDbInterface) {
            return ["FAILURE"];
        }
        $authid = $challenge->authid;
        $user = $this->getUserDb()->get($authid);
        if (!$user) {
            return ["FAILURE"];
        }
        $keyToUse = $user['key'];
        $token = base64_encode(hash_hmac('sha256', json_encode($challenge), $keyToUse, true));
        if ($token != $signature) {
            return ["FAILURE"];
        }
        $authDetails = ["authmethod" => "wampcra", "authrole" => "user", "authid" => $challenge->authid, "authprovider" => $challenge->authprovider];
        return ["SUCCESS", $authDetails];
    }