Exemplo n.º 1
0
 public function validateRequest(RequestInterface $request, ResponseInterface $response)
 {
     if (!$request->request('client_id')) {
         $response->setError(400, 'invalid_request', 'Missing parameter: "client_id" is required');
         return false;
     }
     /*
      * Ensure that the client_id existed
      */
     $client_id = $request->request('client_id');
     if (!($client = $this->storage->getClientDetails($client_id))) {
         $response->setError(400, 'invalid_client', 'The client id supplied is invalid');
         return false;
     }
     $this->client = $client;
     return true;
 }
Exemplo n.º 2
0
 /** @dataProvider provideStorage */
 public function testSaveClient(ClientInterface $storage)
 {
     if ($storage instanceof NullStorage) {
         $this->markTestSkipped('Skipped Storage: ' . $storage->getMessage());
         return;
     }
     $clientId = 'some-client-' . rand();
     // create a new client
     $success = $storage->setClientDetails($clientId, 'somesecret', 'http://test.com', 'client_credentials', 'clientscope1');
     $this->assertTrue($success);
     // valid client_id
     $details = $storage->getClientDetails($clientId);
     $this->assertEquals($details['client_secret'], 'somesecret');
     $this->assertEquals($details['redirect_uri'], 'http://test.com');
     $this->assertEquals($details['grant_types'], 'client_credentials');
     $this->assertEquals($details['scope'], 'clientscope1');
 }