Exemplo n.º 1
0
 /**
  * @return bool
  * @throws \openid\exceptions\InvalidOpenIdMessageException
  */
 public function isValid()
 {
     //check identifier
     if (isset($this->message[OpenIdOAuth2Extension::paramNamespace('_')]) && $this->message[OpenIdOAuth2Extension::paramNamespace('_')] == OpenIdOAuth2Extension::NamespaceUrl) {
         if (is_null($this->getClientId())) {
             throw new InvalidOpenIdMessageException(sprintf(OpenIdErrorMessages::OAuth2MissingRequiredParam, 'client_id'));
         }
         if (is_null($this->getScope())) {
             throw new InvalidOpenIdMessageException(sprintf(OpenIdErrorMessages::OAuth2MissingRequiredParam, 'scope'));
         }
         if (is_null($this->getState())) {
             throw new InvalidOpenIdMessageException(sprintf(OpenIdErrorMessages::OAuth2MissingRequiredParam, 'state'));
         }
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public function testCheckSetupOAuth2ExtensionSubView()
 {
     //set login info
     $user = User::where('identifier', '=', 'sebastian.marcet')->first();
     Auth::login($user);
     $scope = array(sprintf('%s/resource-server/read', $this->current_realm), sprintf('%s/resource-server/read.page', $this->current_realm), sprintf('%s/resource-server/write', $this->current_realm), sprintf('%s/resource-server/delete', $this->current_realm), sprintf('%s/resource-server/update', $this->current_realm), sprintf('%s/resource-server/update.status', $this->current_realm), sprintf('%s/resource-server/regenerate.secret', $this->current_realm));
     $params = array(OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_NS) => OpenIdProtocol::OpenID2MessageType, OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_Mode) => OpenIdProtocol::SetupMode, OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_Realm) => "https://www.test.com/", OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_ReturnTo) => "https://www.test.com/oauth2", OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_Identity) => "http://specs.openid.net/auth/2.0/identifier_select", OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_ClaimedId) => "http://specs.openid.net/auth/2.0/identifier_select", OpenIdOAuth2Extension::paramNamespace() => OpenIdOAuth2Extension::NamespaceUrl, OpenIdOAuth2Extension::param(OpenIdOAuth2Extension::ClientId) => $this->oauth2_client_id, OpenIdOAuth2Extension::param(OpenIdOAuth2Extension::Scope) => implode(' ', $scope), OpenIdOAuth2Extension::param(OpenIdOAuth2Extension::State) => uniqid());
     $response = $this->action("POST", "OpenIdProviderController@endpoint", $params);
     $this->assertResponseStatus(302);
     $content = $response->getContent();
 }