Check to ensure the auth parameters
satisfy the rule of the guard

@param array  $auth
@param array  $signature
@param string $prefix
@throws SignatureKeyException
@return bool
339772
public function check(array $auth, array $signature, $prefix)
    {
        if (! isset($auth[$prefix . 'key'])) {
            throw new SignatureKeyException('The authentication key has not been set');
        }

        if ($auth[$prefix . 'key'] !== $signature[$prefix . 'key']) {
            throw new SignatureKeyException('The authentication key is not valid');
        }

        return true;
    }
483703
protected function getKey(array $auth)
    {
        with($key = $this->getNewKey())->setPassword(array_get($auth, 'keyphrase'));

        return $key;
    }
1310275
public function verify($key, $signature, $input)
    {
        $signedInput = $this->sign($input, $key);

        return $this->timingSafeEquals($signedInput, $signature);
    }
97281
public function useAuthentication($auth, array $options = [])
    {
        if (!($auth instanceof AuthStrategyInterface)) {
            $auth = $this->getAuthFactory()->get($auth);
            $auth->setOptions($options);
        }

        $this->dispatcher->addListener(Events::ON_REQUEST_EVENT, [
            $auth,
            'auth'
        ]);
    }
264581
protected function hasCredentials(array $credentials, $guard = null)
    {
        $provider = $this->app->make('auth')->guard($guard)->getProvider();

        $user = $provider->retrieveByCredentials($credentials);

        return $user && $provider->validateCredentials($user, $credentials);
    }
544608
public function check($signature)
    {
        if (is_array($signature) and isset($signature['sig'])) {
            $signature = $signature['sig'];
        }

        if (!is_string($signature)) {
            throw new \InvalidArgumentException('signature must be string, or present in array or parameters');
        }

        return $signature == $this->signed['sig'];
    }
1157872
protected static function _matchAgentAgainstSignatures($userAgent, $signatures)
    {
        $userAgent = strtolower($userAgent);
        foreach ($signatures as $signature) {
            if (!empty($signature)) {
                if (strpos($userAgent, $signature) !== false) {
                    // Browser signature was found in user agent string
                    return true;
                }
            }
        }
        return false;
    }
501994
protected function arrayKey($key, $prefix)
    {
        $arrayKey = substr($key, strlen($prefix)+1);
        return is_bool($arrayKey) ? '' : $arrayKey;
    }
1234414
public static function verifySignature($message, $signature, $signatureKey, $algorithm = 'MD5')
    {
        if (isset($signature)) {
            if ($algorithm === 'MD5') {
                $hash = md5($message . $signatureKey);
            } else if (in_array($algorithm, array('SHA', 'SHA1', 'SHA-1'))) {
                $hash = sha1($message . $signatureKey);
            } else {
                $hash = hash('sha256', $message . $signatureKey);
            }

            if (strcmp($signature, $hash) == 0) {
                return true;
            }
        }

        return false;
    }
990124
public function verifySignature(?string $signature = null): bool
	{
		// check merchantId and accountId from request
		if (
			$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
			|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
		) {
			throw new InvalidSignatureException();
		}

		if ($signature === null) {
			$signature = $this->signature;
		}

		// Compute the signature for specified arguments, and compare it to the specified signature.

		$out = [];
		$out[] = 'merchantId=' . $this->getRequestMerchantId();
		$out[] = 'accountId=' . $this->getRequestAccountId();
		foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
			if ($this->{$property} !== null) {
				$value = $this->{$property};

				if (in_array($property, self::$FLOAT_ARGS, true)) {
					$value = number_format($value, 2, '.', '');
				} elseif (in_array($property, self::$BOOL_ARGS, true)) {
					$value = $value ? '1' : '0';
				}

				$out[] = sprintf('%s=%s', $property, $value);
			}
		}

		$out[] = 'password=' . $this->getMerchantConfig()->password;

		$sig = $this->hashFunction(implode('&', $out));

		if ($sig === $signature) {
			return true;
		}

		throw new InvalidSignatureException();
	}
329074
private function payload(array $auth, array $params)
    {
        $payload = array_merge($auth, $params);
        $payload = array_change_key_case($payload, CASE_LOWER);

        ksort($payload);

        return $payload;
    }
407829
public function check_signature($request, $consumer, $token, $signature) {

        $built = $this->build_signature($request, $consumer, $token);

        // Check for zero length, although unlikely here
        if (strlen($built) == 0 || strlen($signature) == 0) {
            return false;
        }

        if (strlen($built) != strlen($signature)) {
            return false;
        }

        // Avoid a timing leak with a (hopefully) time insensitive compare
        $result = 0;
        for ($i = 0; $i < strlen($signature); $i++) {
            $result |= ord($built{$i}) ^ ord($signature{$i});
        }

        return $result == 0;

    }
589267
protected function keyToNormalizeMethod($key, $prefix)
    {
        $arrayKey = "$prefix:$key";

        if (!isset($this->_methodCache[$arrayKey])) {

            $method = $prefix . ucfirst(Type::camelCase(str_replace([' ', '.'],'_', $key)));

            $this->_methodCache[$arrayKey] = method_exists($this, $method) ? $method : false;

        }

        return $this->_methodCache[$arrayKey];

    }
225164
public static function authenticateRequest($auth)
    {
        // this is a little tricky. We have TWO ways of doing this
        // 1. Does the security token for jobs md5 correctly? If so, good.

        $val = \Core::make('config/database')->get('concrete.security.token.jobs') . ':' . DIRNAME_JOBS;
        if (md5($val) == $auth) {
            return true;
        }
    }
563926
private function onAuthenticateHandler($authMethod, $authMethodInfo, Realm $realm, Session $session, AuthenticateMessage $msg)
    {

        $onAuthenticateSuccess = function ($res) use ($realm, $session) {

            if (count($res) < 1) {
                $session->abort(new \stdClass(), 'thruway.error.authentication_failure');

                return;
            }

            // we should figure out a way to have the router send the welcome
            // message so that the roles and extras that go along with it can be
            // filled in
            if ($res[0] === 'SUCCESS') {
                $this->sendWelcomeMessage($session, $res[1]);
            } elseif (isset($res[0]) && $res[0] === 'FAILURE') {
                $this->abortSessionUsingResponse($session, $res);
            } else {
                $session->abort(new \stdClass(), 'thruway.error.authentication_failure');
            }
        };

        $onAuthenticateError = function () use ($session) {
            Logger::error($this, 'onauthenticate rejected the promise');
            $session->abort(new \stdClass(), 'thruway.error.unknown');
        };

        $extra                    = new \stdClass();
        $extra->challenge_details = $session->getAuthenticationDetails()->getChallengeDetails();

        $arguments                = new \stdClass();
        $arguments->extra         = $extra;
        $arguments->authid        = $session->getAuthenticationDetails()->getAuthId();
        $arguments->challenge     = $session->getAuthenticationDetails()->getChallenge();
        $arguments->signature     = $msg->getSignature();
        $arguments->authmethod    = $authMethod;
        $arguments->hello_message = $session->getHelloMessage();

        // now we send our authenticate information to the RPC
        $onAuthenticateHandler = $authMethodInfo['handlers']->onauthenticate;

        $this->session->call($onAuthenticateHandler, [$arguments])
            ->then($onAuthenticateSuccess, $onAuthenticateError);

    }
460120
public function check(array $auth, array $signature, $prefix)
    {
        if (! isset($auth[$prefix . 'version'])) {
            throw new SignatureVersionException('The version has not been set');
        }

        if ($auth[$prefix . 'version'] !== $signature[$prefix . 'version']) {
            throw new SignatureVersionException('The signature version is not correct');
        }

        return true;
    }
410261
public function verify(SignedJwt $jwt, VerificationContext $verificationContext, array &$errors) : bool
    {
        $verifiers = [
            new SignatureVerifier($verificationContext->getSigner()),
            new AudienceVerifier($verificationContext->getAudience()),
            new ExpirationVerifier(),
            new NotBeforeVerifier(),
            new IssuerVerifier($verificationContext->getIssuer()),
            new SubjectVerifier($verificationContext->getSubject())
        ];
        $isVerified = true;

        /** @var IVerifier $verifier */
        foreach ($verifiers as $verifier) {
            $error = '';

            if (!$verifier->verify($jwt, $error)) {
                $isVerified = false;
                $errors[] = $error;
            }
        }

        return $isVerified;
    }