<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>Maugrim The Reaper's Blog - Openid and Yadis</title>
    <link>http://blog.astrumfutura.com/</link>
    <description>Pádraic Brady on PHP, PHP Game Development and More</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.1 - http://www.s9y.org/</generator>
    <pubDate>Sat, 21 Jun 2008 20:40:56 GMT</pubDate>

    <image>
        <url>http://blog.astrumfutura.com/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Maugrim The Reaper's Blog - Openid and Yadis - Pádraic Brady on PHP, PHP Game Development and More</title>
        <link>http://blog.astrumfutura.com/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Another OAuth Library Is Born</title>
    <link>http://blog.astrumfutura.com/archives/382-Another-OAuth-Library-Is-Born.html</link>
            <category>Openid and Yadis</category>
            <category>PHP General</category>
            <category>PHP Security</category>
            <category>Zend Framework</category>
    
    <comments>http://blog.astrumfutura.com/archives/382-Another-OAuth-Library-Is-Born.html#comments</comments>
    <wfw:comment>http://blog.astrumfutura.com/wfwcomment.php?cid=382</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.astrumfutura.com/rss.php?version=2.0&amp;type=comments&amp;cid=382</wfw:commentRss>
    

    <author>nospam@example.com (Pádraic Brady)</author>
    <content:encoded>
    I&#039;ve spent some time over the last week, and I have completed an initial pass at writing an OAuth Consumer in PHP5. I&#039;m biased, but it&#039;s a nice chunk of code capable of fairly routine POST based OAuth requests using either an Authorized header, or a raw url encoded POST request body. My main remaining task is final cleanup, included refactoring, rolling my final set of acceptance tests into PHPUnit from SimpleTest, and adding support for HTTP GET, RSA, and a storage API so tokens can be saved in the background rather than outside the API.&lt;br /&gt;
&lt;br /&gt;
I wrote up a quick example script using the current source code - bear in mind the final API will be tweaked but this is a close match for what I&#039;d expect to become final (I&#039;ll await community feedback before finalising anything!).&lt;br /&gt;
&lt;br /&gt;
You can grab the code, which is geared up for integration into the Zend Framework as a Zend_Oauth component, from my proposals repository at &lt;a href=&quot;http://svn.astrumfutura.org/zendframework/trunk/&quot;&gt;http://svn.astrumfutura.org/zendframework/trunk/&lt;/a&gt; (proposed components are in /trunk/library/Proposed). I fully expect to refactor a similar core library specifically for use with PEAR in the very near future.&lt;br /&gt;
&lt;br /&gt;
Onwards with the example! I&#039;m using the &lt;a href=&quot;http://ma.gnolia.com&quot;&gt;Ma.gnolia bookmarking service&#039;s&lt;/a&gt; API (version 2) here. If you intend actually running the example, you will need to create a Ma.gnolia account and visit &lt;a href=&quot;http://ma.gnolia.com/applications/new&quot;&gt;http://ma.gnolia.com/applications/new&lt;/a&gt; to register an application to get hold of an OAuth Consumer Key. Registering an application is a bit confusing - but basically create an imaginary one (e.g. &quot;Super Duper OAuth Test Application&quot;. Since you&#039;ll be the only user for now, you can use it across any OAuth testing regardless of application name. In the code, replace CONSUMER_KEY and CONSUMER_KEY_SECRET strings with the real thing.&lt;br /&gt;
&lt;br /&gt;
The example isn&#039;t explained here - if you&#039;re unfamiliar with OAuth I&#039;ll explain it better in the future when this is all closer to completion. For now refer to the &lt;a href=&quot;http://oauth.net/core/1.0/&quot;&gt;OAuth Core 1.0 Specification&lt;/a&gt; (the starting sections are pretty good at explaining things). The amount of code is indicative of features being wrapped around the existing API as they are not yet integrated directly (e.g. using Sessions to store temporary tokens instead of an internally referenced database). Also note that the example creates a new Access Key every single request (generally the annoyance of authorising yourself every time doesn&#039;t exist in a completed solution &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;).&lt;br /&gt;
&lt;br /&gt;
What does the example do? Simply checks how many bookmarks members of the OAuth Ma.gnolia Group have saved. Think it was 126 or so. The printed response is XML.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;&lt;a href=&quot;http://www.php.net/session_start&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;session_start&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;require_once&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Zend/Oauth/Consumer.php&#039;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$options&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;requestScheme&#039;&lt;/span&gt; =&amp;gt; Zend_Oauth::&lt;span style=&quot;color: #006600;&quot;&gt;REQUEST_SCHEME_HEADER&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;version&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;1.0&#039;&lt;/span&gt;, &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// there is only a 1.0 version for now &amp;lt;img src=&amp;quot;/templates/default/img/emoticons/wink.png&amp;quot; alt=&amp;quot;;-)&amp;quot; style=&amp;quot;display: inline; vertical-align: bottom;&amp;quot; class=&amp;quot;emoticon&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;signatureMethod&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;HMAC-SHA1&#039;&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;localUrl&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;http://path/to/this/file.php&#039;&lt;/span&gt;, &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// change to this file&#039;s local URL&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;requestTokenUrl&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;http://ma.gnolia.com/oauth/get_request_token&#039;&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;userAuthorisationUrl&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;http://ma.gnolia.com/oauth/authorize&#039;&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;accessTokenUrl&#039;&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;http://ma.gnolia.com/oauth/get_access_token&#039;&lt;/span&gt;,&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// replace with your own real application consumer key and key secret!&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$consumer&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Zend_Oauth_Consumer&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;CONSUMER_KEY&#039;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;CONSUMER_KEY_SECRET&#039;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$options&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;!&lt;a href=&quot;http://www.php.net/isset&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;isset&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;ACCESS_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;!&lt;a href=&quot;http://www.php.net/empty&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;empty&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$consumer&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getAccessToken&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_GET&lt;/span&gt;, &lt;a href=&quot;http://www.php.net/unserialize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;unserialize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;REQUEST_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;ACCESS_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/serialize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;serialize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$consumer&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getRequestToken&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;REQUEST_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/serialize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;serialize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$consumer&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;redirect&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/unserialize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;unserialize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;ACCESS_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;ACCESS_TOKEN&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$methodUrl&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;http://ma.gnolia.com/api/rest/2/bookmarks_count&#039;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rawData&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$token&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;toQueryString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$methodUrl&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$consumer&lt;/span&gt;, &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;group&#039;&lt;/span&gt;=&amp;gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;oauth&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$client&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Zend_Http_Client;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$client&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setUri&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$methodUrl&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$client&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setMethod&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;Zend_Http_Client::&lt;span style=&quot;color: #006600;&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$client&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setRawData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rawData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$client&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;request&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type: &#039;&lt;/span&gt; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getHeader&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$response&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getBody&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can comment on the formal Zend Framework proposal for a Zend_Oauth at &lt;a href=&quot;http://framework.zend.com/wiki/pages/viewpage.action?pageId=37957&quot;&gt;http://framework.zend.com/wiki/pages/viewpage.action?pageId=37957&lt;/a&gt;.  
    </content:encoded>
    <dc:creator>P&#225;draic Brady</dc:creator>

    <pubDate>Sat, 21 Jun 2008 20:40:56 +0000</pubDate>
    <guid isPermaLink="false">http://blog.astrumfutura.com/archives/382-guid.html</guid>
    <category>oauth</category>
<category>openid</category>
<category>openid and yadis</category>
<category>pear</category>
<category>php</category>
<category>php general</category>
<category>php security</category>
<category>zend framework</category>
<category>zf proposal</category>
<creativeCommons:license>http://creativecommons.org/licenses/by/1.0/</creativeCommons:license>
</item>
<item>
    <title>Services_Oauth and Zend_Oauth Revisited</title>
    <link>http://blog.astrumfutura.com/archives/381-Services_Oauth-and-Zend_Oauth-Revisited.html</link>
            <category>Openid and Yadis</category>
            <category>PHP General</category>
            <category>PHP Security</category>
            <category>Zend Framework</category>
    
    <comments>http://blog.astrumfutura.com/archives/381-Services_Oauth-and-Zend_Oauth-Revisited.html#comments</comments>
    <wfw:comment>http://blog.astrumfutura.com/wfwcomment.php?cid=381</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://blog.astrumfutura.com/rss.php?version=2.0&amp;type=comments&amp;cid=381</wfw:commentRss>
    

    <author>nospam@example.com (Pádraic Brady)</author>
    <content:encoded>
    With my cryptographic efforts exhausted (I&#039;ll wait for the weekend to figure out the intricacies of ext/openssl API changes across 15+ PHP versions), my attention has wandered back to OAuth.&lt;br /&gt;
&lt;br /&gt;
What is OAuth? &quot;An open protocol to allow secure API authentication in a simple and standard method from desktop and web applications&quot; - &lt;a href=&quot;http://oauth.net/&quot;&gt;http://oauth.net/&lt;/a&gt;. If you&#039;re not yet up to speed it&#039;s being adopted by both Yahoo and Google. Interested now? &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Starting yesterday, I opened up my IDE, updated PHPUnit, and got cracking. At the current rate of development a Consumer is likely at the weekend. I&#039;ve already started writing up a formal proposal for PEAR and, of course, the Zend Framework also. I&#039;m thankful the OAuth specification is this simple - it&#039;s one of the easiest to read specifications I&#039;ve had to pleasure to work with. The cost of that is a certain level of vagueness on some points, but nothing you can&#039;t overcome with a little reading of the OAuth mailing list.&lt;br /&gt;
&lt;br /&gt;
Of course with any new Specification, there comes potential implementation trouble hard on its heels. Talk about an OAuth Core 1.1 Specification is well underway on the mailing list which drags up concerns over the future compatibility of an early API based on 1.0. I&#039;m not too worried here since these types of APIs are often extremely simple and flexible, very much belying the enormous work and mountain of source code existing in the background.&lt;br /&gt;
&lt;br /&gt;
The other concern are Extensions. OAuth 1.0 allows for Extensions, of which there are several Drafts already. One of the more interesting Extensions is OAuth Discovery 1.0 which will create a dependency (when implemented) on Zend_Service_Yadis (for the Yadis 1.0 Protocol). This Extension will be more formally integrated into OAuth Core 1.1 so it&#039;s optional only if you ignore it hard enough! The Yadis component is one of those semi-lost proposals - it&#039;s now hitting 15 months on the Zend Review list waiting for finalisation and comment (it has been released on PEAR as beta already).&lt;br /&gt;
&lt;br /&gt;
The other reason this is a bit distracting is that a 15 month old proposal inevitably misses 15 months of clarifications, developments and the rapidly shifting sands of the specification community. For example, Yadis 1.0 Specification is making the move into the upcoming OASIS XRI Resolution 2.0 Specification (Section 6) and there is a new OAuth driven XRDS-Simple 1.0 Specification Draft. These all accumulate unless you regularly assess them all and make incremental changes.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve had people beating the bushes trying to to flush me out into the open so they can request I get this started. They&#039;ll be happy to hear it&#039;s now in progress.&lt;br /&gt;
&lt;br /&gt;
Edit: A few people were curious about why OAuth is worth paying attention to. The simplest convincing answer is to point out the alternative. Say you use GMail and a website asks you to import your contact data - how does it access that data?&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://www.codinghorror.com/blog/images/yelp-friends-check-fail.png&quot; width=&quot;95%&quot; alt=&quot;Oooh! Let&#039;s get everyones secret password to GMail! ;)&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Do you want every Tom, Dick and Harry website to potentially store your GMail email address and password for some future nefarious purpose? Yet people put their absolute trust in this model day after day on social networking sites.&lt;br /&gt;
&lt;br /&gt;
Do yourself a favour - if you&#039;re a developer writing an API make it possible for web sites to access your users&#039; data without having to beg them for their username and so-called secret private password.  
    </content:encoded>
    <dc:creator>P&#225;draic Brady</dc:creator>

    <pubDate>Wed, 18 Jun 2008 11:48:25 +0000</pubDate>
    <guid isPermaLink="false">http://blog.astrumfutura.com/archives/381-guid.html</guid>
    <category>oauth</category>
<category>openid</category>
<category>openid and yadis</category>
<category>pear</category>
<category>php general</category>
<category>php security</category>
<category>xri</category>
<category>yadis</category>
<category>zend framework</category>
<creativeCommons:license>http://creativecommons.org/licenses/by/1.0/</creativeCommons:license>
</item>
<item>
    <title>PEAR::Encryption and Zend_Crypt Revisited</title>
    <link>http://blog.astrumfutura.com/archives/380-PEAREncryption-and-Zend_Crypt-Revisited.html</link>
            <category>Openid and Yadis</category>
            <category>PHP General</category>
            <category>PHP Security</category>
            <category>Zend Framework</category>
    
    <comments>http://blog.astrumfutura.com/archives/380-PEAREncryption-and-Zend_Crypt-Revisited.html#comments</comments>
    <wfw:comment>http://blog.astrumfutura.com/wfwcomment.php?cid=380</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://blog.astrumfutura.com/rss.php?version=2.0&amp;type=comments&amp;cid=380</wfw:commentRss>
    

    <author>nospam@example.com (Pádraic Brady)</author>
    <content:encoded>
    It&#039;s been a while since I did some active ZF/PEAR component development. It&#039;s been one of those 6 month periods where time to commit was a rarity for a few reasons. So now that I&#039;m back on the road, where to? First of all I need to remember/reset my subversion password for the ZF repository! Whenever I don&#039;t use a password regularly I always forget it &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;.&lt;br /&gt;
&lt;br /&gt;
Zend_Crypt was accepted into the Incubator last Autumn with 3 initial broad implementable areas:&lt;br /&gt;
&lt;br /&gt;
1. Hash Message Authentication Code Algorithm&lt;br /&gt;
&lt;br /&gt;
HMAC is commonly used these days. You can find it in use in both OpenID and OAuth for creating secure authenticated signatures of exchanged data using a key known only by both parties to a message exchange. Obviously the benefit is to prove that any message you received does come from the expected party, and not an intercepting middle-man who&#039;s done some tinkering!&lt;br /&gt;
&lt;br /&gt;
The Zend_Crypt version relies heavily on the available hashing support (i.e. the hash, mhash, openssl extensions, or the native md5/sha1 functions) which is a point of refactoring at the moment since I&#039;ve added a new Zend_Crypt::hash() method which covers all the extensions and native functions for hashing.&lt;br /&gt;
&lt;br /&gt;
2. Diffie-Hellman Key Agreement Protocol&lt;br /&gt;
&lt;br /&gt;
One of the problems with connecting two random systems is ensuring the messages they exchange can be authenticated. A common solution is HMAC (as above) but HMAC requires that both parties have a shared secret with which to sign/verify message signatures. Diffie Hellman is a protocol for establishing such a common secret in such a way that a middle-man intercepting all setup messages between the systems cannot replicate the shared secret. The secret is in the math (which I won&#039;t bore you with!).&lt;br /&gt;
&lt;br /&gt;
There are two major updates here. First of all the Zend_Crypt_Math library now fully supports the GMP extension. As a general rule - if you&#039;re doing big integer (i.e. &gt; 32 bits) math then you should install gmp. Especially for Diffie Hellman use which is horribly slow on bcmath! It is incredibly faster than bcmath at certain types of calculations. My test suite for all of Zend_Crypt takes upwards of 2 minutes to run using bcmath, and only 6 seconds using gmp.&lt;br /&gt;
&lt;br /&gt;
The second major change, since gmp is an uncertain extension to be installed on any system, is to add in support for Dmitry Stogov&#039;s ext/openssl changes coming in PHP 5.3. Once he no doubt upgrades the 5.3 extension to use openssl 0.9.8h (unless we like typos which narrow key ranges &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;) ext/openssl will add a more commonly available and extremely fast source of Diffie Hellman key generation.&lt;br /&gt;
&lt;br /&gt;
3. Hashing Wrapper&lt;br /&gt;
&lt;br /&gt;
Since hashing is an annoying part of some applications, there&#039;s a new static Zend_Crypt::hash() method (which accepts the same arguments as the hash() function in PHP 5.2 assuming you didn&#039;t disable it!). This offers a simple means to navigate the 4+ methods PHP can use to create hashes. Support extends to hash, mhash, openssl, and the two md5/sha1 native functions. It&#039;s particularly useful for hashing algorithms unsupported by native functions - such as sha256, ripemd, gost, etc. If it can&#039;t find anything to support your hashing method you get a neat catchable exception.&lt;br /&gt;
&lt;br /&gt;
Why bother with this? If it doesn&#039;t matter to you - you can make your own if..else method. But it&#039;s handy to have a single all encompassing one built into the framework. And yes, it does support both hex and binary output.&lt;br /&gt;
&lt;br /&gt;
4. (PROPOSED) RSA Public Key Cryptography&lt;br /&gt;
&lt;br /&gt;
One of the more recent trends in web services has been the rapid adoption by large service providers of the OAuth open authentication standard. OAuth offers a single best practice standard for allowing users authenticate to web service APIs and has seen wide adoption from the likes of Yahoo and Google. The recent move towards OAuth by Google revealed they would require the use of RSA-SHA1 message signing.&lt;br /&gt;
&lt;br /&gt;
The RSA proposal is intended as an OO wrapper around existing openssl functionality. It goes a bit further though since openssl has, shall we say, less than stellar documentation. My RSA test suite breaks at three points between PHP 5.2 versions, and 5.3. So poor documentation, and poor API compatibility across major versions. Besides solving this problem, having an OO wrapper allows for a more OO approach. Having a single API which works the same across all PHP versions from 5.1.4 to 5.3.0 can be quite valuable when you need a maintainable component relying on RSA in the ZF.&lt;br /&gt;
&lt;br /&gt;
If accepted it&#039;s first use will be support RSA-SHA1 for my OAuth implementation. Some refactoring later I might look into a more general component which utilises RSA and other algorithms and offers broad based certificate support. HMAC will already cover other OAuth signing methods like HMAC-SHA1 and HMAC-SHA256.&lt;br /&gt;
&lt;br /&gt;
Of course since a lot of this is already in beta for PEAR, you can expect the same updates rolled in there at a future date. That should level the playing field nicely for finishing up (finally) my open source OpenID For PHP library before a PEAR proposal for it is put up for voting.&lt;br /&gt;
&lt;br /&gt;
RSA for PEAR I might look at - there&#039;s already a native implementation in PEAR for PHP4, but there&#039;s no PHP5 version, and it doesn&#039;t attempt to leverage off ext/openssl at all (which be a lot faster!).  
    </content:encoded>
    <dc:creator>P&#225;draic Brady</dc:creator>

    <pubDate>Tue, 17 Jun 2008 11:22:29 +0000</pubDate>
    <guid isPermaLink="false">http://blog.astrumfutura.com/archives/380-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/1.0/</creativeCommons:license>
</item>
<item>
    <title>Kicking The Bad Habit Of Being An Overworked Paddy</title>
    <link>http://blog.astrumfutura.com/archives/337-Kicking-The-Bad-Habit-Of-Being-An-Overworked-Paddy.html</link>
            <category>Irishisms</category>
            <category>Openid and Yadis</category>
            <category>PHP Game Development</category>
            <category>PHP General</category>
            <category>PHP Security</category>
            <category>Zend Framework</category>
    
    <comments>http://blog.astrumfutura.com/archives/337-Kicking-The-Bad-Habit-Of-Being-An-Overworked-Paddy.html#comments</comments>
    <wfw:comment>http://blog.astrumfutura.com/wfwcomment.php?cid=337</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://blog.astrumfutura.com/rss.php?version=2.0&amp;type=comments&amp;cid=337</wfw:commentRss>
    

    <author>nospam@example.com (Pádraic Brady)</author>
    <content:encoded>
    It&#039;s hard to believe we are already almost 1/12 of the distance into 2008. By now all of you have broken your new year resolutions. I know I&#039;ve broken several at a minimum!&lt;br /&gt;
&lt;br /&gt;
After some months of desperate oft-despairing struggling with work schedules I&#039;ve finally once and for all conquered my lack of free time. It&#039;s an ingenious solution - I&#039;m taking a small break from work before rekindling an interest in financial services in these doubtful times (ask Société Générale if you want to know how doubtful, or the US Federal Rserve).&lt;br /&gt;
&lt;br /&gt;
The outcome of this reorganisation of my career direction is twofold. Firstly I get extra bags of cash. Secondly, I get slightly more vacation time. Thirdly, it won&#039;t require as much overtime. Fourthly, there&#039;s less chance of last-minute-scrambling which became exceptionally evident over the last few months as the Irish market continues to swell (in defiance of the laws of EU Economics). Of course added together this provides more of my most sought after commodity - personal time.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s left is how to use this new-found wealth. In between the extra pub-crawling exercises, engagements as the designated baggage mule on shopping excursions, and the other things an average 20-something is inclined to do, I want to enjoy some travel, take up writing again, and commit some completion time to the open source projects I contribute to.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve been a very bad boy in that regard in the last six months and at one point I became an absolute nightmare for anyone who needed to contact me by email. It was not my finest hour, and I seriously doubt I escaped with a pristine reputation for being dependable. C&#039;est la vie. A few of these &quot;instances&quot; shall we call them, have since been resolved to my satisfaction so I&#039;m 95% back to nominal form as a powerhouse of innovation, inspiration and ingenuity (see, even my ego is back rockin&#039; at full throttle!). Yep, you can always measure the normality of an Irishman by his level of self-directed sarcasm &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;.&lt;br /&gt;
&lt;br /&gt;
Anyways, enough self-critical analysis - it weakens the ego - since I&#039;m back in fine form after two extremes (a two month vacation, and a four month chaotic period of non-stop work) I have the luxury of directing some of this time where it was always supposed to be: in supplementing my PHP experience with some open source doodling and manic self-promotion &lt;img src=&quot;http://blog.astrumfutura.com/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;. The first target of my ire is a small project with Till Klampaeckel (Seek. Kill. Destroy.). After that is PHPSpec 0.3.0 (Exterminate! Exterminate! Exterminate!). After that is that frickin&#039; promise-but-never-effing-do component for implementing a Yadis service (Off With His Head! Off With His Head!). I swear that thing has been sitting in a personal subversion repo begging for a few final hours of attention!&lt;br /&gt;
&lt;br /&gt;
After that I&#039;m taking a long breather, attending oodles of conferences, and finding something with a lot of words to write.  
    </content:encoded>
    <dc:creator>P&#225;draic Brady</dc:creator>

    <pubDate>Thu, 24 Jan 2008 20:58:42 +0000</pubDate>
    <guid isPermaLink="false">http://blog.astrumfutura.com/archives/337-guid.html</guid>
    <category>irishisms</category>
<category>openid and yadis</category>
<category>php game development</category>
<category>php general</category>
<category>php security</category>
<category>zend framework</category>
<creativeCommons:license>http://creativecommons.org/licenses/by/1.0/</creativeCommons:license>
</item>

</channel>
</rss>