<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cakebaker &#187; openid</title>
	<atom:link href="http://cakebaker.42dh.com/tags/openid/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bugfix release v2010-12-08 of the OpenID component</title>
		<link>http://cakebaker.42dh.com/2010/12/08/bugfix-release-v2010-12-08-of-the-openid-component/</link>
		<comments>http://cakebaker.42dh.com/2010/12/08/bugfix-release-v2010-12-08-of-the-openid-component/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 15:53:40 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1465</guid>
		<description><![CDATA[There is a new bugfix release of the OpenID component available: https://github.com/cakebaker/openid-component/downloads. This release fixes a bug in the isOpenIDResponse() method. So far this method only recognized OpenID responses from a GET request. But as I had to learn, there are OpenID providers (e.g. Hyves) responding with a POST request&#8230; So, if you use the [...]]]></description>
			<content:encoded><![CDATA[<p>There is a new bugfix release of the OpenID component available: <a href="https://github.com/cakebaker/openid-component/downloads">https://github.com/cakebaker/openid-component/downloads</a>. </p>
<p>This release fixes a bug in the isOpenIDResponse() method. So far this method only recognized OpenID responses from a GET request. But as I had to learn, there are OpenID providers (e.g. <a href="http://hyves.nl">Hyves</a>) responding with a POST request&#8230; So, if you use the isOpenIDResponse() method, please upgrade to the new version. </p>
<p>However, this bug not only affected the component itself but also the <a href="http://code.42dh.com/openid/">examples</a> and the <a href="https://github.com/cakebaker/openid-component-example">example application</a>. They contained code that looked like:</p>
<pre>
<code>if ($this-&gt;RequestHandler-&gt;isPost()) {
    // make OpenID request
} elseif ($this-&gt;Openid-&gt;isOpenIDResponse()) {
    // handle OpenID response
}</code>
</pre>
<p>This snippet will fail if the response from an OpenID provider is a POST request. Instead it should look like:</p>
<pre>
<code>if ($this-&gt;RequestHandler-&gt;isPost() &amp;&amp; !$this-&gt;Openid-&gt;isOpenIDResponse()) {
    // make OpenID request
} elseif ($this-&gt;Openid-&gt;isOpenIDResponse()) {
    // handle OpenID response
}</code>
</pre>
<p>Please fix this in your code if you followed the examples.</p>
<p>Thanks go to Sam Mousa for reporting this issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/12/08/bugfix-release-v2010-12-08-of-the-openid-component/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bugfix release for the OpenID component &amp; an example application</title>
		<link>http://cakebaker.42dh.com/2010/07/19/bugfix-release-for-the-openid-component-an-example-application/</link>
		<comments>http://cakebaker.42dh.com/2010/07/19/bugfix-release-for-the-openid-component-an-example-application/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 14:23:38 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1435</guid>
		<description><![CDATA[Last week I received a mail from a user of the OpenID component in which he described that it wasn&#8217;t possible to login with OpenIDs from claimID and Blogger. After some debugging I found the reason for this problem: a bug in the isOpenIDResponse() method. The method only recognized responses from providers using OpenID 2.0, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I received a mail from a user of the <a href="http://code.42dh.com/openid/">OpenID component</a> in which he described that it wasn&#8217;t possible to login with OpenIDs from <a href="http://claimid.com/">claimID</a> and <a href="http://blogger.com">Blogger</a>. After some debugging I found the reason for this problem: a bug in the isOpenIDResponse() method. The method only recognized responses from providers using OpenID 2.0, but not from providers still using the older OpenID 1.x&#8230; So, if you are using this method in your code, please <a href="http://github.com/cakebaker/openid-component/downloads">upgrade</a> to the latest version (v2010-07-17).</p>
<p>I also got asked whether there is an example application that shows the usage of the OpenID component. As I already use a very simple application to test the component manually, I pushed this application to <a href="http://github.com/cakebaker/openid-component-example">GitHub</a> (you can see the application in action on <a href="http://openid-example.42dh.com/">http://openid-example.42dh.com/</a>). I hope this will make it easier for some of you to get started with the OpenID component.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/07/19/bugfix-release-for-the-openid-component-an-example-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenID component v2010-05-19 released</title>
		<link>http://cakebaker.42dh.com/2010/05/19/openid-component-v2010-05-19-released/</link>
		<comments>http://cakebaker.42dh.com/2010/05/19/openid-component-v2010-05-19-released/#comments</comments>
		<pubDate>Wed, 19 May 2010 07:51:25 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1412</guid>
		<description><![CDATA[As mentioned in the title, I released a new version of the OpenID component today. It&#8217;s a maintenance release: the only change is an update of the bundled PHP OpenID library from version 2.1.2 to 2.2.2. With this change you no longer have to patch the OpenID library if you are working with PHP 5.3. [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in the title, I released a new version of the OpenID component today. It&#8217;s a maintenance release: the only change is an update of the bundled <a href="http://github.com/openid/php-openid/">PHP OpenID library</a> from version 2.1.2 to 2.2.2. With this change you no longer have to patch the OpenID library if you are working with PHP 5.3.</p>
<p>To update, simply replace the OpenID component and the content of the &#8220;vendors/Auth&#8221; folder (and its subfolders) with the files from the zip archive.</p>
<p>You can <a href="http://github.com/cakebaker/openid-component/downloads">download</a> the new version from Github.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/05/19/openid-component-v2010-05-19-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Support for Google Apps OpenIDs</title>
		<link>http://cakebaker.42dh.com/2010/04/13/support-for-google-apps-openids/</link>
		<comments>http://cakebaker.42dh.com/2010/04/13/support-for-google-apps-openids/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 15:13:06 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1356</guid>
		<description><![CDATA[In a recent comment John mentioned that the OpenID component doesn&#8217;t work with Google Apps OpenIDs. And he was right. The reason it didn&#8217;t work is that Google introduced it&#8217;s own OpenID discovery protocol as they faced challenges not addressed by the current version (2.0) of the OpenID standard. And this means such OpenIDs are [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://cakebaker.42dh.com/2008/02/06/new-version-of-the-openid-component/#comment-156388">recent comment</a> John mentioned that the <a href="http://code.42dh.com/openid">OpenID component</a> doesn&#8217;t work with <a href="http://www.google.com/apps/">Google Apps</a> OpenIDs. And he was right.</p>
<p>The reason it didn&#8217;t work is that Google introduced it&#8217;s own <a href="http://groups.google.com/group/google-federated-login-api/web/openid-discovery-for-hosted-domains">OpenID discovery protocol</a> as they faced challenges not addressed by the current version (2.0) of the OpenID standard. And this means such OpenIDs are not recognized by current OpenID libraries. For this reason, Google provides with <a href="http://code.google.com/p/php-openid-apps-discovery/">php-openid-apps-discovery</a> an add-on to the <a href="http://openidenabled.com/php-openid/">PHP OpenID</a> library.</p>
<p>I integrated this add-on into the OpenID component as an optional feature. You have to enable it with:</p>
<pre>
<code>public $components = array('Openid' =&gt; array('accept_google_apps' =&gt; true));</code>
</pre>
<p>I made it an optional feature because it introduces an additional step to the authentication process: the provided OpenID url is sent to Google to figure out whether it is a Google Apps OpenID. And this makes the authentication process a bit slower. Hence I think you should have a choice whether you want to use this feature.</p>
<p>The new version of the <a href="http://code.42dh.com/openid">OpenID component</a> doesn&#8217;t contain any other new features/bugfixes. </p>
<p>You can download the component from <a href="http://github.com/cakebaker/openid-component/downloads">Github</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/04/13/support-for-google-apps-openids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accepting the Google OpenID with PHP OpenID</title>
		<link>http://cakebaker.42dh.com/2009/12/31/accepting-the-google-openid-with-php-openid/</link>
		<comments>http://cakebaker.42dh.com/2009/12/31/accepting-the-google-openid-with-php-openid/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 16:45:04 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[openid]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1322</guid>
		<description><![CDATA[If you are using the PHP OpenID library (which is also used by my OpenID component for CakePHP), it is possible that you get an &#8220;Invalid OpenID&#8221; error when you try to login with the Google OpenID (https://www.google.com/accounts/o8/id), or any other OpenID that uses &#8220;https&#8221;. In this case, the following steps might help to fix [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using the <a href="http://openidenabled.com/php-openid/">PHP OpenID library</a> (which is also used by my <a href="http://code.42dh.com/openid/">OpenID component</a> for CakePHP), it is possible that you get an &#8220;Invalid OpenID&#8221; error when you try to login with the Google OpenID (https://www.google.com/accounts/o8/id), or any other OpenID that uses &#8220;https&#8221;.</p>
<p>In this case, the following steps might help to fix this issue:</p>
<ul>
<li>Ensure you have Curl and OpenSSL installed</li>
<li>Enable the Curl and OpenSSL extensions in your php.ini (on Archlinux this file is found in /etc/php/):
<pre>
<code>extension=curl.so
extension=openssl.so</code>
</pre>
</li>
<li>Restart your web server</li>
</ul>
<p>Now the error message should disappear and you should be able to log in with the Google OpenID. </p>
<p>&#8212;-</p>
<p>That&#8217;s it for 2009. It was a rather lazy year on this blog from my side (I didn&#8217;t even manage to do a redesign&#8230;), and so I hope I will be a bit less lazy with writing on this blog in 2010.</p>
<p>Anyway, thank you for reading this blog, and for all your comments and emails. A Happy New Year everyone &#038; cu in 2010 :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/12/31/accepting-the-google-openid-with-php-openid/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Attribute Exchange support for the OpenID component</title>
		<link>http://cakebaker.42dh.com/2009/12/12/attribute-exchange-support-for-the-openid-component/</link>
		<comments>http://cakebaker.42dh.com/2009/12/12/attribute-exchange-support-for-the-openid-component/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 17:30:11 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1314</guid>
		<description><![CDATA[The OpenID Attribute Exchange specification (or AX for short) has been around for quite a while, though I ignored it so far because at the time it was introduced (almost) no OpenID provider supported it. However, after Yahoo! announced they support Attribute Exchange, and someone recently mentioned it in a mail, it was time for [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://openid.net/specs/openid-attribute-exchange-1_0.html">OpenID Attribute Exchange specification</a> (or AX for short) has been around for quite a while, though I ignored it so far because at the time it was introduced (almost) no OpenID provider supported it. However, after Yahoo! <a href="http://developer.yahoo.net/blog/archives/2009/12/yahoo_openid_now_with_attribute_exchange.html">announced</a> they support Attribute Exchange, and someone recently mentioned it in a mail, it was time for me to have a look at it.</p>
<p>AX is in principle the &#8220;big brother&#8221; of the <a href="http://openid.net/specs/openid-simple-registration-extension-1_0.html">Simple Registration Extension</a> (or SReg for short). Whereas SReg only allows you to retrieve nine commonly requested pieces of information, AX allows you to retrieve any identity information. And theoretically it also allows you to store/update your identity information at your OpenID provider. But it seems like no OpenID provider supports this feature&#8230;</p>
<p>Let&#8217;s have a look at an example.</p>
<p>First the login method:</p>
<pre>
<code>// app/controllers/users_controller.php
class UsersController extends AppController {
    public $components = array('Openid', 'RequestHandler');

    public function login() {
        $realm = 'http://'.$_SERVER['SERVER_NAME'];
        $returnTo = $realm . '/users/login';

        if ($this-&gt;RequestHandler-&gt;isPost()) {
            $this-&gt;makeOpenIDRequest($this-&gt;data['User']['openid_identifier'], $returnTo, $realm);
        } elseif ($this-&gt;Openid-&gt;isOpenIDResponse()) {
            $this-&gt;handleOpenIDResponse($returnTo);
        }
    }
}</code>
</pre>
<p>The next step is to implement the makeOpenIDRequest() method. For each attribute we want to retrieve, we have to create an Auth_OpenID_AX_AttrInfo object with the respective attribute type. A list of possible types is available on <a href="http://www.axschema.org/types/">http://www.axschema.org/types/</a>. Though there are many types defined, OpenID providers usually only support a small subset of those types.</p>
<p>The &#8220;1&#8243; we pass to the make() method specifies the number of values we want for this type. In this example it doesn&#8217;t make much sense to specify a value other than &#8220;1&#8243;, but for other types it is theoretically possible to have multiple values (for example you could have defined multiple email addresses). It is an optional parameter and by default it is &#8220;1&#8243;.</p>
<p>The last parameter specifies whether the value of the attribute is required for our application. This is simply a hint for the OpenID provider so it could display this attribute differently, but it doesn&#8217;t guarantee a value is returned. By default this parameter is &#8220;false&#8221;. </p>
<p>(Update 2010-04-19: Google requires that you set the fourth parameter of the make() method: a string with an alias for the attribute.)</p>
<pre>
<code>private function makeOpenIDRequest($openid, $returnTo, $realm) {
    $attributes[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson', 1, true);
    $this-&gt;Openid-&gt;authenticate($openid, $returnTo, $realm, array('ax' =&gt; $attributes));
}</code>
</pre>
<p>Finally, we have to implement the handleOpenIDResponse() method. As we expect only one value for the attribute we specified, we can use either get() or getSingle() to retrieve its value. getSingle() returns the value whereas get() returns an array. </p>
<pre>
<code>private function handleOpenIDResponse($returnTo) {
    $response = $this-&gt;Openid-&gt;getResponse($returnTo);

    if ($response-&gt;status == Auth_OpenID_SUCCESS) {
        $axResponse = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);

        if ($axResponse) {
            debug($axResponse-&gt;get('http://axschema.org/namePerson'));
            debug($axResponse-&gt;getSingle('http://axschema.org/namePerson'));
        }
    }
}</code>
</pre>
<p>That&#8217;s it. </p>
<p>You can get the new version of the OpenID component from <a href="http://github.com/cakebaker/openid-component">GitHub</a>. If you use SReg in your code and you want to update to this version, please make sure to adapt your code in the following way:</p>
<pre>
<code>// old
$this-&gt;Openid-&gt;authenticate($openid, $returnTo, $realm, array('email'), array('nickname'));

// new
$this-&gt;Openid-&gt;authenticate($openid, $returnTo, $realm, array('sreg_required' =&gt; array('email'), 'sreg_optional' =&gt; array('nickname')));</code>
</pre>
<p>Feedback is welcome :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/12/12/attribute-exchange-support-for-the-openid-component/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>New release of the OpenID component</title>
		<link>http://cakebaker.42dh.com/2009/08/18/new-release-of-the-openid-component/</link>
		<comments>http://cakebaker.42dh.com/2009/08/18/new-release-of-the-openid-component/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 15:24:05 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1235</guid>
		<description><![CDATA[Today I released a new version of the OpenID component. Three changes made it into this release: Almost all external libraries are now included in the package to make the installation a bit easier. Included are the required PHP OpenID library and PEAR DB (which is used if you want to store the OpenID data [...]]]></description>
			<content:encoded><![CDATA[<p>Today I released a new version of the OpenID component. Three changes made it into this release:</p>
<p>Almost all external libraries are now included in the package to make the installation a bit easier. Included are the required <a href="http://www.openidenabled.com/php-openid/">PHP OpenID</a> library and <a href="http://pear.php.net/package/DB">PEAR DB</a> (which is used if you want to store the OpenID data in the database). Not included is the <a href="http://eaut.org">EAUT library</a> as I think this standard is dead (i.e. nobody is using it).</p>
<p>The configuration settings are now set when you add the OpenID component to the $components array of your controller(s):</p>
<pre>
<code>public $components = array('Openid' =&gt; array('use_database' =&gt; true));

or

public $components = array('Openid' =&gt; array('database_config' =&gt; 'name_of_database_config));</code>
</pre>
<p>The old way, using Configure::write(), is no longer supported:</p>
<pre>
<code>Configure::write('Openid.use_database', true);
Configure::write('Openid.database_config', 'name_of_database_config');</code>
</pre>
<p>So, if you upgrade and you use those configuration settings, make sure to adapt your code accordingly.</p>
<p>Last, but not least, I fixed a bug which caused a &#8220;class not found&#8221; error if you used the component in a plugin. </p>
<p>That&#8217;s it. You can get the component from <a href="http://code.42dh.com/openid">http://code.42dh.com/openid</a> or directly from <a href="http://github.com/cakebaker/openid-component">GitHub</a>.</p>
<p>Happy baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2009/08/18/new-release-of-the-openid-component/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to use the OpenID component with the Auth component</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/</link>
		<comments>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:02:39 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[authentication]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994</guid>
		<description><![CDATA[Please note that the hack described in this article no longer works with CakePHP 1.2.3.8166! See Peter&#8217;s comment for a possible solution for the current CakePHP release (1.2.5.x). Some days ago I got asked how you can use the OpenID component together with the Auth component from CakePHP. As I didn&#8217;t knew the answer, I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Please note that the hack described in this article no longer works with CakePHP 1.2.3.8166! See <a href="http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/#comment-133898">Peter&#8217;s comment</a> for a possible solution for the current CakePHP release (1.2.5.x).</strong></p>
<p>Some days ago I got asked how you can use the <a href="http://cakebaker.42dh.com/downloads/openid-component-for-cakephp/">OpenID component</a> together with the Auth component from CakePHP.</p>
<p>As I didn&#8217;t knew the answer, I had to experiment a bit. Even though it was a quite frustrating experience (thanks to the strange design of the Auth component and too much automagic), I finally managed to find a &#8220;solution&#8221;. It is rather a hack, but it seems to work ;-)</p>
<p>Ok, here we go. </p>
<p>The first step is to create the login form. Because the Auth component expects the login credentials to consist of username and password, we have to add a (hidden) field for the password.</p>
<pre>
<code>&lt;?php
// app/views/users/login.ctp
$session-&gt;flash('auth');

echo $form-&gt;create('User', array('action' =&gt; 'login'));
echo $form-&gt;input('username', array('label' =&gt; 'OpenID:'));
echo $form-&gt;input('password', array('type' =&gt; 'hidden'));
echo $form-&gt;end('Login');
?&gt;</code>
</pre>
<p>The next step is to create the UsersController. The login() method is a bit special in this case, it is called three times: when you visit the login form, when you submit the login form, and when you come back from the OpenID provider. The rest of the code should be self-explanatory (if not, please leave a comment).</p>
<pre>
<code>// app/controllers/users_controller.php
class UsersController extends AppController {
    public $components = array('Auth', 'Openid', 'RequestHandler');
 
    public function beforeFilter() {
        $this-&gt;Auth-&gt;loginError = 'Login failed';
    }
    
    public function login() { 
        $returnTo = 'http://'.$_SERVER['SERVER_NAME'].'/users/login';
		
        if ($this-&gt;RequestHandler-&gt;isPost()) {   
    	    $this-&gt;makeOpenIDRequest($this-&gt;data['User']['username'], $returnTo);
        }
    	
        if ($this-&gt;isOpenIDResponse()) {
            $this-&gt;handleOpenIDResponse($returnTo);
        }
    }
    
    private function makeOpenIDRequest($openid, $returnTo) {
        try {
            $this-&gt;Openid-&gt;authenticate($openid, $returnTo, 'http://'.$_SERVER['SERVER_NAME']);
        } catch (Exception $e) {
            // empty
        }
    }
    
    private function isOpenIDResponse() {
        return (count($_GET) &gt; 1);
    }
    
    private function handleOpenIDResponse($returnTo) {
        $response = $this-&gt;Openid-&gt;getResponse($returnTo);
        $this-&gt;Auth-&gt;login($response);
        $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
    }
    
    public function logout() {
        $this-&gt;redirect($this-&gt;Auth-&gt;logout());
    }
}</code>
</pre>
<p>As you can see in the handleOpenIDResponse() method, we pass the OpenID response object to the login method of the Auth component. As the Auth component cannot know how to deal with that object, we have to write some functionality to deal with the response object. For this purpose we have to override the find() method of the User model, as it is the method which is eventually called by the Auth component if you call its login() method. The response object is passed to the find() method in the $conditions array and is available via the strange &#8220;`User`.`id`&#8221; key. The implementation itself is quite simple: you have to return an array with user data if the login was successful, or an empty array if the login was not successful. </p>
<pre>
<code>// app/models/user.php
class User extends AppModel {
    public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {	
        if (is_array($conditions) &amp;&amp; isset($conditions['`User`.`id`'])) {
            $response = $conditions['`User`.`id`'];
			
            if ($response-&gt;status == Auth_OpenID_SUCCESS) {
                return array('User' =&gt; array('openid' =&gt; $response-&gt;identity_url));
            }
			
            return array();
        }

        if (is_array($conditions) &amp;&amp; isset($conditions['User.username']) &amp;&amp; isset($conditions['User.password'])) {
            return array();
        }
		
        return parent::find($conditions, $fields, $order, $recursive);
    }
}</code>
</pre>
<p>Especially if you have only an OpenID column in your table you have to hinder the Auth component from performing a find() operation using the non-existing columns &#8220;username&#8221; and &#8220;password&#8221;, hence the check in the example whether those conditions are set.</p>
<p>With that, it should now be possible to login with your OpenID into your application protected by the Auth component.</p>
<p>I hope this is useful for some of you!</p>
<p>Update (2008-12-24): Fixing some small issues mentioned by <a href="http://lboy.wordpress.com/">lboy</a> in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>MySQL support for OpenID component</title>
		<link>http://cakebaker.42dh.com/2008/08/27/mysql-support-for-openid-component/</link>
		<comments>http://cakebaker.42dh.com/2008/08/27/mysql-support-for-openid-component/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 15:53:37 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=742</guid>
		<description><![CDATA[Up to now the OpenID component stored all data in the file system (in app/tmp/openid) even though the OpenID library provided by JanRain also supports databases. I wanted to provide support for MySQL for quite some time, but I wanted too much (i.e. the perfect CakePHP solution *g*), and so this feature never materialized&#8230; Anyway, [...]]]></description>
			<content:encoded><![CDATA[<p>Up to now the <a href="http://cakebaker.42dh.com/downloads/openid-component-for-cakephp/">OpenID component</a> stored all data in the file system (in app/tmp/openid) even though the <a href="http://openidenabled.com/">OpenID library</a> provided by <a href="http://janrain.com/">JanRain</a> also supports databases. I wanted to provide support for MySQL for quite some time, but I wanted too much (i.e. the perfect CakePHP solution *g*), and so this feature never materialized&#8230;</p>
<p>Anyway, in the meantime I used a more pragmatic approach and used what&#8217;s already there. So, instead of using CakePHP for accessing the database, the superseded <a href="http://pear.php.net/package/DB">PEAR DB</a> package is used&#8230;</p>
<p>If you want to use the OpenID component with MySQL, you have to perform the following steps:</p>
<ul>
<li>Download the latest version of the <a href="http://cakebaker.42dh.com/downloads/openid-component-for-cakephp/">OpenID component</a></li>
<li>If you already use the component, simply replace it with the new version. In the other case follow the installation instructions from the download page</li>
<li>Execute the SQL script included in the zip file to create the necessary tables</li>
<li>Download the <a href=http://pear.php.net/package/PEAR/"">PEAR base system</a> and place PEAR.php from the zip in vendors/pear</li>
<li>Download <a href="http://pear.php.net/package/DB/">PEAR DB</a> and place DB.php and the DB folder from the zip in vendors/pear</li>
<li>In the file which uses the OpenID component add: Configure::write(&#8216;Openid.use_database&#8217;, true);</li>
<li>If you want to use a database configuration other than &#8220;default&#8221; you can specify it with: Configure::write(&#8216;Openid.database_config&#8217;, &#8216;name_of_database_config&#8217;);</li>
</ul>
<p>With that, the data should now get stored in the database. If there are any questions/problems/whatever, please leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/08/27/mysql-support-for-openid-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EAUT support for the OpenID component</title>
		<link>http://cakebaker.42dh.com/2008/08/09/eaut-support-for-the-openid-component/</link>
		<comments>http://cakebaker.42dh.com/2008/08/09/eaut-support-for-the-openid-component/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 13:32:35 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[eaut]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=665</guid>
		<description><![CDATA[If you are a geek, you probably have no problem to use an URL as an identifier. But for &#8220;normal&#8221; users it is a bit strange to use an URL, they are more accustomed to use an email address as an identifier. And so a protocol has been defined to transform email addresses to URLs: [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a geek, you probably have no problem to use an URL as an identifier. But for &#8220;normal&#8221; users it is a bit strange to use an URL, they are more accustomed to use an email address as an identifier. And so a protocol has been defined to transform email addresses to URLs: <a href="http://eaut.org/">Email Address to URL Transformation</a> (or short: EAUT). </p>
<p>The protocol works in the following way (optimal scenario):</p>
<ul>
<li>The user enters his email address, e.g. daniel@example.com</li>
<li>The server makes a request to http://example.com to get the location of an XML file with EAUT information</li>
<li>The server retrieves the XML file</li>
<li>Using the information from the XML file, the server transforms the email address to an URL, e.g. daniel@example.com to http://daniel.example.com</li>
<li>The server can now use this URL, for example, to perform an OpenID authentication</li>
</ul>
<p>For the curious the XML file for the transformation described above:</p>
<pre>
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)"&gt;
    &lt;XRD&gt;
        &lt;Service priority="0"&gt;
            &lt;Type&gt;http://specs.eaut.org/1.0/template&lt;/Type&gt;
            &lt;URI&gt;http://%7Busername%7D.example.com&lt;/URI&gt;
        &lt;/Service&gt;
    &lt;/XRD&gt;
&lt;/xrds:XRDS&gt;</code>
</pre>
<p>Ok, that was a short introduction to EAUT, for more details I recommend to have a look at the <a href="http://eaut.org/specs/1.0/">specification</a>. </p>
<p>If you want to use EAUT in your application, you do not have to care much about the protocol details. There are <a href="http://eaut.org/code/">libraries</a> for PHP, Python, and Rails, which do the heavy work for you. </p>
<p>And to make it even easier for cakebakers, I integrated EAUT support into the latest version of the <a href="http://cakebaker.42dh.com/downloads/openid-component-for-cakephp/">OpenID component</a>. To enable it, you simply have to place the EAUT library (Email.php) in the vendors/Auth/Yadis folder. And with that it should also be possible for your users to use an email address instead of an OpenID for authentication purposes.</p>
<p>PS: On September 13/14 there will be a <a href="http://noserub.com/blog/archives/53-NoseRub-DevCamp-13.-14.-September-2008.html">NoseRub DevCamp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/08/09/eaut-support-for-the-openid-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

