Issues

ZF-10851: It is not possible to set OAuth Realm

Issue Type: Bug Created: 2010-12-19T13:43:21.000+0000 Last Updated: 2011-05-03T19:28:14.000+0000 Status: Resolved Fix version(s): - 1.11.6 (05/May/11)

Reporter: Nicolas Ruflin (ruflin) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Oauth

Related issues: Attachments: - ZF-10851.patch

Description

I could not figure how to set the OAuth Realm for a Zend_Oauth_Client. The general problem is that all params would exist but are not implemented in the client.

The toHeader function in Zend_Oauth_Token_Access looks as following:

<pre class="highlight">
    public function toHeader(
        $url, Zend_Oauth_Config_ConfigInterface $config, array $customParams = null, $realm = null
    ) {

As can be seen, the fourth paraemter is $realm. But in Zend_Oauth_Client it is not used as can be seen below.

<pre class="highlight">
            $oauthHeaderValue = $this->getToken()->toHeader(
                $this->getUri(true),
                $this->_config,
                $this->_getSignableParametersAsQueryString(),
            );

It is necessary that the realm can be set for the client, otherwise the whole realm parameter does not make sense and calls to Yahoo OAuth are not possible. I extended the client as following:

<pre class="highlight">
            $oauthHeaderValue = $this->getToken()->toHeader(
                $this->getUri(true),
                $this->_config,
                $this->_getSignableParametersAsQueryString(),
                $this->_getRealm(),

            );

I added a getter and a setter for the realm. Like this it works.

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2010-12-20T07:23:16.000+0000

I've attached a fix for this issue. It modifies Zend_Oauth_Config to add a 'realm' attribute, and modifies Zend_Oauth_Client:250 to add realm to the toHeader() call as outlined in reporter's post.

I haven't had much experience yet with using Zend_Oauth, so i'm not entirely certain this is the best way to add the ability to configure the realm. Comments?

Posted by Nicolas Ruflin (ruflin) on 2010-12-20T07:34:23.000+0000

Looks good. That's exactly the way I implemented it and it works. I also think this is the right way to add it.

Thanks for the fix.

Posted by Adam Lundrigan (adamlundrigan) on 2011-05-02T22:54:38.000+0000

Fixed in trunk r23946

Posted by Ralph Schindler (ralph) on 2011-05-03T19:28:14.000+0000

Fixed in release branch 1.11 at r23983

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts