public function validate($validateRequiredAttributes = true)
    {
        $claimedId = $this->getClaimedId();
        if (empty($claimedId)) {
            return false;
        }
        $params = [
            'openid.assoc_handle' => $this->data['openid_assoc_handle'],
            'openid.signed' => $this->data['openid_signed'],
            'openid.sig' => $this->data['openid_sig'],
        ];

        if (isset($this->data['openid_ns'])) {
            /* We're dealing with an OpenID 2.0 server, so let's set an ns
            Even though we should know location of the endpoint,
            we still need to verify it by discovery, so $server is not set here*/
            $params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
        } elseif (isset($this->data['openid_claimed_id']) && $this->data['openid_claimed_id'] != $this->data['openid_identity']) {
            // If it's an OpenID 1 provider, and we've got claimed_id,
            // we have to append it to the returnUrl, like authUrlV1 does.
            $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $claimedId;
        }

        if (!$this->compareUrl($this->data['openid_return_to'], $this->returnUrl)) {
            // The return_to url must match the url of current request.
            return false;
        }

        $serverInfo = $this->discover($claimedId);

        foreach (explode(',', $this->data['openid_signed']) as $item) {
            $value = $this->data['openid_' . str_replace('.', '_', $item)];
            $params['openid.' . $item] = $value;
        }

        $params['openid.mode'] = 'check_authentication';

        $response = $this->sendRequest($serverInfo['url'], 'POST', $params);

        if (preg_match('/is_valid\s*:\s*true/i', $response)) {
            if ($validateRequiredAttributes) {
                return $this->validateRequiredAttributes();
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
public function validate($validateRequiredAttributes = true)
    {
        $claimedId = $this->getClaimedId();
        if (empty($claimedId)) {
            return false;
        }
        $params = [
            'openid.assoc_handle' => $this->data['openid_assoc_handle'],
            'openid.signed' => $this->data['openid_signed'],
            'openid.sig' => $this->data['openid_sig'],
        ];

        if (isset($this->data['openid_ns'])) {
            /* We're dealing with an OpenID 2.0 server, so let's set an ns
            Even though we should know location of the endpoint,
            we still need to verify it by discovery, so $server is not set here*/
            $params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
        } elseif (isset($this->data['openid_claimed_id']) && $this->data['openid_claimed_id'] != $this->data['openid_identity']) {
            // If it's an OpenID 1 provider, and we've got claimed_id,
            // we have to append it to the returnUrl, like authUrlV1 does.
            $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $claimedId;
        }

        if (!$this->compareUrl($this->data['openid_return_to'], $this->returnUrl)) {
            // The return_to url must match the url of current request.
            return false;
        }

        $serverInfo = $this->discover($claimedId);

        foreach (explode(',', $this->data['openid_signed']) as $item) {
            $value = $this->data['openid_' . str_replace('.', '_', $item)];
            $params['openid.' . $item] = $value;
        }

        $params['openid.mode'] = 'check_authentication';

        $response = $this->sendRequest($serverInfo['url'], 'POST', $params);

        if (preg_match('/is_valid\s*:\s*true/i', $response)) {
            if ($validateRequiredAttributes) {
                return $this->validateRequiredAttributes();
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
public function validate ( $ validateRequiredAttributes = true ) { $ claimedId = $ this -> getClaimedId ( ) ; if ( empty ( $ claimedId ) ) { return false ; } $ params = [ 'openid.assoc_handle' => $ this -> data [ 'openid_assoc_handle' ] , 'openid.signed' => $ this -> data [ 'openid_signed' ] , 'openid.sig' => $ this -> data [ 'openid_sig' ] , ] ; if ( isset ( $ this -> data [ 'openid_ns' ] ) ) { /* We're dealing with an OpenID 2.0 server, so let's set an ns
            Even though we should know location of the endpoint,
            we still need to verify it by discovery, so $server is not set here*/ $ params [ 'openid.ns' ] = 'http://specs.openid.net/auth/2.0' ; } elseif ( isset ( $ this -> data [ 'openid_claimed_id' ] ) && $ this -> data [ 'openid_claimed_id' ] != $ this -> data [ 'openid_identity' ] ) { // If it's an OpenID 1 provider, and we've got claimed_id, // we have to append it to the returnUrl, like authUrlV1 does. $ this -> returnUrl .= ( strpos ( $ this -> returnUrl , '?' ) ? '&' : '?' ) . 'openid.claimed_id=' . $ claimedId ; } if ( ! $ this -> compareUrl ( $ this -> data [ 'openid_return_to' ] , $ this -> returnUrl ) ) { // The return_to url must match the url of current request. return false ; } $ serverInfo = $ this -> discover ( $ claimedId ) ; foreach ( explode ( ',' , $ this -> data [ 'openid_signed' ] ) as $ item ) { $ value = $ this -> data [ 'openid_' . str_replace ( '.' , '_' , $ item ) ] ; $ params [ 'openid.' . $ item ] = $ value ; } $ params [ 'openid.mode' ] = 'check_authentication' ; $ response = $ this -> sendRequest ( $ serverInfo [ 'url' ] , 'POST' , $ params ) ; if ( preg_match ( '/is_valid\s*:\s*true/i' , $ response ) ) { if ( $ validateRequiredAttributes ) { return $ this -> validateRequiredAttributes ( ) ; } else { return true ; } } else { return false ; } }
Performs OpenID verification with the OP.
@param bool $validateRequiredAttributes whether to validate required attributes.
@return bool whether the verification was successful.
Performs OpenID verification with the OP .