public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check HTTP basic auth headers for client id/secret
		if (!is_null($request->headers('PHP_AUTH_USER')) && !is_null($request->headers('PHP_AUTH_PW')))
		{
			$clientData = array(
				'client_id'     => $request->headers('PHP_AUTH_USER'),
				'client_secret' => $request->headers('PHP_AUTH_PW')
			);
		}

		// if we allow credentials via request body look there
		if ($this->config['allow_credentials_in_request_body'])
		{
			// check for client id in request
			if (!is_null($request->request('client_id')))
			{
				$clientData = array(
					'client_id'     => $request->request('client_id'),
					'client_secret' => $request->request('client_secret')
				);
			}
		}

		// must have client id
		if (!isset($clientData['client_id']) || $clientData['client_id'] == '')
		{
			$message = $this->config['allow_credentials_in_request_body'] ? ' or body' : '';
			$response->setError(400, 'invalid_client', 'Client credentials were not found in the headers'.$message);
			return false;
		}

		// check to see if we have client secret
		if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '')
		{
			// invalid if we dont have client secret and public clients are off
			if (!$this->config['allow_public_clients'])
			{
				$response->setError(400, 'invalid_client', 'client credentials are required');
				return false;
			}

			// check storage if client is public client
			if (!$this->storage->isPublicClient($clientData['client_id']))
			{
				$response->setError(400, 'invalid_client', 'This client is invalid or must authenticate using a client secret');
				return false;
			}
		}
		// if we do have a secret lets verify them
		elseif ($this->storage->checkClientCredentials($clientData['client_id'], $clientData['client_secret']) === false)
		{
			$response->setError(400, 'invalid_client', 'The client credentials are invalid');
			return false;
		}

		// store data locally
		$this->clientData = $clientData;
		return true;
	}
public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check HTTP basic auth headers for client id/secret
		if (!is_null($request->headers('PHP_AUTH_USER')) && !is_null($request->headers('PHP_AUTH_PW')))
		{
			$clientData = array(
				'client_id'     => $request->headers('PHP_AUTH_USER'),
				'client_secret' => $request->headers('PHP_AUTH_PW')
			);
		}

		// if we allow credentials via request body look there
		if ($this->config['allow_credentials_in_request_body'])
		{
			// check for client id in request
			if (!is_null($request->request('client_id')))
			{
				$clientData = array(
					'client_id'     => $request->request('client_id'),
					'client_secret' => $request->request('client_secret')
				);
			}
		}

		// must have client id
		if (!isset($clientData['client_id']) || $clientData['client_id'] == '')
		{
			$message = $this->config['allow_credentials_in_request_body'] ? ' or body' : '';
			$response->setError(400, 'invalid_client', 'Client credentials were not found in the headers'.$message);
			return false;
		}

		// check to see if we have client secret
		if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '')
		{
			// invalid if we dont have client secret and public clients are off
			if (!$this->config['allow_public_clients'])
			{
				$response->setError(400, 'invalid_client', 'client credentials are required');
				return false;
			}

			// check storage if client is public client
			if (!$this->storage->isPublicClient($clientData['client_id']))
			{
				$response->setError(400, 'invalid_client', 'This client is invalid or must authenticate using a client secret');
				return false;
			}
		}
		// if we do have a secret lets verify them
		elseif ($this->storage->checkClientCredentials($clientData['client_id'], $clientData['client_secret']) === false)
		{
			$response->setError(400, 'invalid_client', 'The client credentials are invalid');
			return false;
		}

		// store data locally
		$this->clientData = $clientData;
		return true;
	}
public function validateRequest ( RequestInterface $ request , ResponseInterface $ response ) { // check HTTP basic auth headers for client id/secret if ( ! is_null ( $ request -> headers ( 'PHP_AUTH_USER' ) ) && ! is_null ( $ request -> headers ( 'PHP_AUTH_PW' ) ) ) { $ clientData = array ( 'client_id' => $ request -> headers ( 'PHP_AUTH_USER' ) , 'client_secret' => $ request -> headers ( 'PHP_AUTH_PW' ) ) ; } // if we allow credentials via request body look there if ( $ this -> config [ 'allow_credentials_in_request_body' ] ) { // check for client id in request if ( ! is_null ( $ request -> request ( 'client_id' ) ) ) { $ clientData = array ( 'client_id' => $ request -> request ( 'client_id' ) , 'client_secret' => $ request -> request ( 'client_secret' ) ) ; } } // must have client id if ( ! isset ( $ clientData [ 'client_id' ] ) || $ clientData [ 'client_id' ] == '' ) { $ message = $ this -> config [ 'allow_credentials_in_request_body' ] ? ' or body' : '' ; $ response -> setError ( 400 , 'invalid_client' , 'Client credentials were not found in the headers' . $ message ) ; return false ; } // check to see if we have client secret if ( ! isset ( $ clientData [ 'client_secret' ] ) || $ clientData [ 'client_secret' ] == '' ) { // invalid if we dont have client secret and public clients are off if ( ! $ this -> config [ 'allow_public_clients' ] ) { $ response -> setError ( 400 , 'invalid_client' , 'client credentials are required' ) ; return false ; } // check storage if client is public client if ( ! $ this -> storage -> isPublicClient ( $ clientData [ 'client_id' ] ) ) { $ response -> setError ( 400 , 'invalid_client' , 'This client is invalid or must authenticate using a client secret' ) ; return false ; } } // if we do have a secret lets verify them elseif ( $ this -> storage -> checkClientCredentials ( $ clientData [ 'client_id' ] , $ clientData [ 'client_secret' ] ) === false ) { $ response -> setError ( 400 , 'invalid_client' , 'The client credentials are invalid' ) ; return false ; } // store data locally $ this -> clientData = $ clientData ; return true ; }
Validate request via client

@param   object  $request   Request object
@param   object  $response  Response object
@return  bool    Result of auth
Validate request via client