<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.2" -->
<rss version="2.0">
    <channel>
        <title>Authenticating_Against_the_Joomla!_Users_Table[ Search for &quot;&quot;]</title>
        <description></description>
        <link>http://xataface.com/wiki/index.php?-action=single_record_search&amp;-table=wiki&amp;page_id=%3D93&amp;-cursor=0&amp;-skip=0&amp;-limit=30&amp;-mode=list&amp;--subsearch=</link>
        <lastBuildDate>Sat, 25 May 2013 01:45:43 +0100</lastBuildDate>
        <generator>FeedCreator 1.7.2</generator>
        <item>
            <title>Authenticating_Against_the_Joomla!_Users_Table</title>
            <link>http://www.xataface.com/wiki/Authenticating_Against_the_Joomla!_Users_Table</link>
            <description>&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Field&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page name&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;Authenticating_Against_the_Joomla!_Users_Table&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page id&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;93&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Content&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;p&gt;Xataface is able to use the joomla users table to authenticate against so that, you can allow your users to log into your Xataface application using the same credentials as they use to access your joomla website. Achieving this level of integration requires 2 simple steps : 1 - Set up the [_auth] section of your conf.ini file to reference the joomla users table and the correct username and password columns. 2 - Create a delegate class for the joomla users table to be able to decrypt the password set in the table. 
&lt;h2 id=&quot;toc0&quot;&gt;Configure the conf.ini file&lt;/h2&gt;
 Joomla users table is named jos_users. So you have to declare this table in the conf.ini file. 
&lt;pre&gt;&lt;code&gt;[_auth]
users_table = jos_users
username_column = username
password_column = password&lt;/code&gt;&lt;/pre&gt;

 Note that username_column and password_column are very simple... 
&lt;h2 id=&quot;toc1&quot;&gt;Create a delegate class for your users table&lt;/h2&gt;
 Now we have to create a delegate class for the users table to decrypt the passwords set in joomla. Joomla uses a custom md5 encryption. 
&lt;h3 id=&quot;toc2&quot;&gt;Joomla encryption&lt;/h3&gt;
 When a user is setting a password in joomla, the system does several things : 1 - generate a random key containing alphanumeric characters example :  
&lt;pre&gt;&lt;code&gt;8NdiRqLRKLHaNwudJ3InJknsew9sc7pL&lt;/code&gt;&lt;/pre&gt;

 2 - concate the clear entered password with the random key example :  
&lt;pre&gt;&lt;code&gt;password8NdiRqLRKLHaNwudJ3InJknsew9sc7pL&lt;/code&gt;&lt;/pre&gt;

 3 - doing a md5 encryption on the result string example :  
&lt;pre&gt;&lt;code&gt;md5(password8NdiRqLRKLHaNwudJ3InJknsew9sc7pL = f2b1fb3996442db549c1ed1a1eebbfe1&lt;/code&gt;&lt;/pre&gt;

 4 - concate the md5 string with the random key separated by &amp;quot;:&amp;quot; example : 
&lt;pre&gt;&lt;code&gt;f2b1fb3996442db549c1ed1a1eebbfe1:8NdiRqLRKLHaNwudJ3InJknsew9sc7pL&lt;/code&gt;&lt;/pre&gt;

 So it's a great encryption but xataface doesn't know how to do that. Here is the utility of the delegate class. We will define a function inside which could compare the entered password in xataface with the joomla stored password. 
&lt;h3 id=&quot;toc3&quot;&gt;Creating the delegate class&lt;/h3&gt;
 1 - Add a jos_users directory in your directory table 2 - Create a jos_users.php file inside this new directory 
&lt;h3 id=&quot;toc4&quot;&gt;Creating the decrypt password function&lt;/h3&gt;
 Before posting this code, I would like to thank fantomasdm who created this function. So here is the code of the function to paste directly in the jos_users delegate class : 
&lt;pre&gt;&lt;code&gt;&amp;lt;?
class tables_jos_users {
    
function password__serialize($password){

   $app =&amp;amp; Dataface_Application::getInstance(); 
   $query = &amp;quot;SELECT id, gid, block, password, usertype FROM jos_users where username='&amp;quot;.$_POST['UserName'].&amp;quot;'&amp;quot;;
   $result = mysql_query($query,$app-&amp;gt;db()) or die(&amp;quot;Query failed&amp;quot; . mysql_error() );

   $line = mysql_fetch_array($result, MYSQL_ASSOC);
   mysql_free_result($result);

   $arraypass=explode(&amp;quot;:&amp;quot;, $linea['password']);
   $key=$arraypass[1];
   
   $ret = md5(trim($password).$key).&amp;quot;:&amp;quot;.$key;
   return $ret;
} 
}
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;

 Save your file and test the result. Enjoy ! ;-)&lt;/p&gt;

&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Keywords&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;joomla authentication md5&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Language&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;en&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description>
            <author>Authenticating_Against_the_Joomla!_Users_Table</author>
        </item>
    </channel>
</rss>
