Ejemplo n.º 1
0
 public function parseRequest(OpenIdRequest $request, RequestContext $context)
 {
     try {
         $ax_request = new OpenIdAXRequest($request->getMessage());
         if (!$ax_request->isValid()) {
             return;
         }
         $attributes = $ax_request->getRequiredAttributes();
         $data = array();
         foreach ($attributes as $attr) {
             array_push($data, $attr);
         }
         $partial_view = new PartialView($this->view, array("attributes" => $data));
         $context->addPartialView($partial_view);
     } catch (Exception $ex) {
         $this->log_service->error($ex);
     }
 }
Ejemplo n.º 2
0
 public function parseRequest(OpenIdRequest $request, RequestContext $context)
 {
     try {
         $simple_reg_request = new OpenIdSREGRequest($request->getMessage());
         if (!$simple_reg_request->isValid()) {
             return;
         }
         $attributes = $simple_reg_request->getRequiredAttributes();
         $opt_attributes = $simple_reg_request->getOptionalAttributes();
         $policy_url = $simple_reg_request->getPolicyUrl();
         $attributes = array_merge($attributes, $opt_attributes);
         $view_data = array('attributes' => array_keys($attributes));
         if (!empty($policy_url)) {
             $view_data['policy_url'] = $policy_url;
         }
         $partial_view = new PartialView($this->view, $view_data);
         $context->addPartialView($partial_view);
     } catch (Exception $ex) {
         $this->log_service->error($ex);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param OpenIdRequest $request
  * @param RequestContext $context
  * @return mixed|void
  */
 public function parseRequest(OpenIdRequest $request, RequestContext $context)
 {
     try {
         $oauth2_request = new OpenIdOAuth2Request($request->getMessage());
         if (!$oauth2_request->isValid()) {
             return;
         }
         $scopes = $oauth2_request->getScope();
         $client_id = $oauth2_request->getClientId();
         $client = $this->client_service->getClientById($client_id);
         // do some validations to allow show the oauth2 sub view...
         if (is_null($client)) {
             $this->log_service->warning_msg(sprintf("OpenIdOAuth2Extension: client id %s not found!.", $client_id));
             return;
         }
         //check is redirect uri is allowed for client
         $redirect_uri = $request->getParam(OpenIdProtocol::OpenIDProtocol_ReturnTo);
         if (!$client->isUriAllowed($redirect_uri)) {
             $this->log_service->warning_msg(sprintf("OpenIdOAuth2Extension: url %s not allowed for client id %s ", $redirect_uri, $client_id));
             return;
         }
         //check if requested client is allowed to use this scopes
         if (!$client->isScopeAllowed($scopes)) {
             $this->log_service->warning_msg(sprintf("OpenIdOAuth2Extension: scope %s not allowed for client id %s ", $scopes, $client_id));
             return;
         }
         $scopes = explode(' ', $scopes);
         //get scopes entities
         $requested_scopes = $this->scope_service->getScopesByName($scopes);
         // set view data
         $return_to = $request->getParam(OpenIdProtocol::OpenIDProtocol_ReturnTo);
         $url_parts = @parse_url($return_to);
         $return_to = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path'];
         $partial_view = new PartialView($this->view, array('requested_scopes' => $requested_scopes, 'app_name' => $client->getApplicationName(), 'app_logo' => $client->getApplicationLogo(), 'redirect_to' => $return_to, 'website' => $client->getWebsite(), 'dev_info_email' => $client->getDeveloperEmail()));
         $context->addPartialView($partial_view);
     } catch (Exception $ex) {
         $this->log_service->error($ex);
     }
 }