Ejemplo n.º 1
0
 /**
  * Check authorize parameters
  *
  * @return array Authorize request parameters
  *
  * @throws
  */
 public function checkAuthorizeParams()
 {
     // Get required params
     $clientId = $this->server->getRequestHandler()->getParam('client_id');
     if (is_null($clientId)) {
         throw new Exception\InvalidRequestException('client_id');
     }
     $redirectUri = $this->server->getRequestHandler()->getParam('redirect_uri');
     if (is_null($redirectUri)) {
         throw new Exception\InvalidRequestException('redirect_uri');
     }
     // Validate client ID and redirect URI
     $client = $this->server->getClientStorage()->get($clientId, null, $redirectUri, $this->getIdentifier());
     if ($client instanceof ClientEntity === false) {
         throw new Exception\InvalidClientException();
     }
     $state = $this->server->getRequestHandler()->getParam('state');
     if ($this->server->stateParamRequired() === true && is_null($state)) {
         throw new Exception\InvalidRequestException('state', $redirectUri);
     }
     $responseType = $this->server->getRequestHandler()->getParam('response_type');
     if (is_null($responseType)) {
         throw new Exception\InvalidRequestException('response_type', $redirectUri);
     }
     // Ensure response type is one that is recognised
     if (!in_array($responseType, $this->server->getResponseTypes())) {
         throw new Exception\UnsupportedResponseTypeException($responseType, $redirectUri);
     }
     // Validate any scopes that are in the request
     $scopeParam = $this->server->getRequestHandler()->getParam('scope');
     $scopes = $this->validateScopes($scopeParam, $client, $redirectUri);
     return array('client' => $client, 'redirect_uri' => $redirectUri, 'state' => $state, 'response_type' => $responseType, 'scopes' => $scopes);
 }
Ejemplo n.º 2
0
 public function validateClient()
 {
     $clientId = $this->server->getRequestHandler()->getParam('client_id');
     if (is_null($clientId)) {
         throw new Exception\InvalidRequestException('client_id');
     }
     $clientSecret = $this->server->getRequestHandler()->getParam('client_secret');
     if (is_null($clientSecret)) {
         throw new Exception\InvalidRequestException('client_secret');
     }
     $redirectUri = $this->server->getRequestHandler()->getParam('redirect_uri');
     $uriRequired = false;
     if (strpos(get_class($this), "AuthCodeGrant") !== FALSE) {
         $uriRequired = true;
     }
     if (is_null($redirectUri) && $uriRequired) {
         throw new Exception\InvalidRequestException('redirect_uri');
     }
     // Validate client ID and client secret
     $client = $this->server->getClientStorage()->get($clientId, $clientSecret, $redirectUri, $this->getIdentifier());
     if ($client instanceof ClientEntity === false) {
         throw new Exception\InvalidClientException();
     }
     return $client;
 }
Ejemplo n.º 3
0
 /**
  * Return the session client
  *
  * @return \OAuth2\Server\Entity\ClientEntity
  */
 public function getClient()
 {
     if ($this->client instanceof ClientEntity) {
         return $this->client;
     }
     $this->client = $this->server->getClientStorage()->getBySession($this);
     return $this->client;
 }