Exemplo n.º 1
0
 /**
  * Show Auth View
  * 
  * @return  void
  */
 public function authorizeTask()
 {
     //create request & response objects
     $request = OAuth2\Request::createFromGlobals();
     $response = new OAuth2\Response();
     // force query string redirect param
     if (!$request->query('redirect_uri')) {
         throw new Exception('No redirect URI', 400);
     }
     // validate the authorize request
     if (!$this->server->validateAuthorizeRequest($request, $response)) {
         throw new Exception($response->getParameter('error_description'), 400);
     }
     // get the application model (by client ID)
     $application = Application::all()->whereEquals('client_id', $request->query('client_id'))->row();
     // make sure were logged in
     if (User::isGuest()) {
         // redirect to login
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($_SERVER['REQUEST_URI'])), Lang::txt('You must be logged in to authorize %s', $application->get('name')), 'warning');
     }
     // display authorize form
     $this->view->set('application', $application)->display();
 }
Exemplo n.º 2
0
 /**
  * Remove any existing tokens for applications
  * 
  * @return  void
  */
 public function removeTokensTask()
 {
     // [SECURITY] Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.edit', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $ids = Request::getVar('id', array(0));
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we actually have any entries?
     if (count($ids) < 1) {
         // No entries found, so go back to the entries list with
         // a message scolding the user for not selecting anything. Tsk, tsk.
         Notify::warning(Lang::txt('COM_DEVELOPER_SELECT_APPLICATION_TO', $this->_task));
         return $this->cancelTask();
     }
     // loop through each application id
     foreach ($ids as $id) {
         // Load the entry and revoke tokens/codes
         $row = Application::oneOrFail(intval($id));
         $row->revokeAccessTokens();
         $row->revokeRefreshTokens();
         $row->revokeAuthorizationCodes();
     }
     // Set the redirect URL to the main entries listing.
     Notify::success(Lang::txt('COM_DEVELOPER_REVOKE_TOKENS_SUCCESS'));
     $this->cancelTask();
 }
Exemplo n.º 3
0
 /**
  * Build Breadcrumb Trail
  * 
  * @return  void
  */
 protected function _buildPathway()
 {
     // create breadcrumbs
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option);
     }
     // add "API"
     Pathway::append(Lang::txt('COM_DEVELOPER_API'), 'index.php?option=' . $this->_option . '&controller=api');
     // add "Applications"
     Pathway::append(Lang::txt('COM_DEVELOPER_API_APPLICATIONS'), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller);
     // do we have an application
     if ($appid = Request::getInt('id', 0)) {
         $application = Application::oneOrFail($appid);
         // add "Applications"
         Pathway::append($application->get('name'), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&id=' . $appid);
     }
     // add task
     if (isset($this->_task) && !in_array($this->_task, array('view', 'display', 'applications', 'granted'))) {
         // add "Applications"
         Pathway::append(Lang::txt('COM_DEVELOPER_API_APPLICATION_' . strtoupper($this->_task)), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&id=' . $appid . '&task=' . $this->_task);
     }
     // add active
     if ($active = Request::getCmd('active', null)) {
         // add "Applications"
         Pathway::append(Lang::txt(ucfirst($active)), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&id=' . $appid . '&task=' . $this->_task);
     }
 }
Exemplo n.º 4
0
 /**
  * Find Internal Client
  *
  * In separate function so we can call it multiple times.
  * 
  * @return  array  Client detials
  */
 private function findInternalClient()
 {
     // create model and fetch applications matching fitlers
     $application = \Components\Developer\Models\Application::all()->whereEquals('hub_account', 1)->row();
     // make sure we have at least one
     // although it should always only be one
     if (!$application->get('id')) {
         return false;
     }
     // return first as an array
     return $application->toArray();
 }