/** * Parse a new authorize request * * @param string $type The session owner's type * @param string $typeId The session owner's ID * @param array $authParams The authorize request $_GET parameters * * @return string An authorisation code */ public function newAuthorizeRequest($type, $typeId, $authParams = []) { // Create a new session $session = new SessionEntity($this->server); $session->setOwner($type, $typeId); $session->associateClient($authParams['client']); // Create a new auth code $authCode = new AuthCodeEntity($this->server); $authCode->setId(SecureKey::generate()); $authCode->setRedirectUri($authParams['redirect_uri']); $authCode->setExpireTime(time() + $this->authTokenTTL); foreach ($authParams['scopes'] as $scope) { $authCode->associateScope($scope); $session->associateScope($scope); } $session->save(); $authCode->setSession($session); $authCode->save(); return $authCode->generateRedirectUri($authParams['state']); }