<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.freedesk.purplepixie.org/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
		<id>http://wiki.freedesk.purplepixie.org/w/index.php?action=history&amp;feed=atom&amp;title=Authentication_Modules</id>
		<title>Authentication Modules - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.freedesk.purplepixie.org/w/index.php?action=history&amp;feed=atom&amp;title=Authentication_Modules"/>
		<link rel="alternate" type="text/html" href="http://wiki.freedesk.purplepixie.org/w/index.php?title=Authentication_Modules&amp;action=history"/>
		<updated>2026-05-12T22:01:21Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.0</generator>

	<entry>
		<id>http://wiki.freedesk.purplepixie.org/w/index.php?title=Authentication_Modules&amp;diff=70&amp;oldid=prev</id>
		<title>Dave: Created page with &quot;Authentication modules provide an alternative authentication method for analyst users.  The following are the base class (that must be extended for an authentication class) an...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.freedesk.purplepixie.org/w/index.php?title=Authentication_Modules&amp;diff=70&amp;oldid=prev"/>
				<updated>2012-08-21T23:55:57Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Authentication modules provide an alternative authentication method for analyst users.  The following are the base class (that must be extended for an authentication class) an...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Authentication modules provide an alternative authentication method for analyst users.&lt;br /&gt;
&lt;br /&gt;
The following are the base class (that must be extended for an authentication class) and the included standard authentication class as an example.&lt;br /&gt;
&lt;br /&gt;
== Authentication Base Class ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php &lt;br /&gt;
/* -------------------------------------------------------------&lt;br /&gt;
This file is part of FreeDESK&lt;br /&gt;
&lt;br /&gt;
FreeDESK is (C) Copyright 2012 David Cutting&lt;br /&gt;
&lt;br /&gt;
FreeDESK is free software: you can redistribute it and/or modify&lt;br /&gt;
it under the terms of the GNU General Public License as published by&lt;br /&gt;
the Free Software Foundation, either version 3 of the License, or&lt;br /&gt;
(at your option) any later version.&lt;br /&gt;
&lt;br /&gt;
FreeDESK is distributed in the hope that it will be useful,&lt;br /&gt;
but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License&lt;br /&gt;
along with FreeDESK.  If not, see www.gnu.org/licenses&lt;br /&gt;
&lt;br /&gt;
For more information see www.purplepixie.org/freedesk/&lt;br /&gt;
-------------------------------------------------------------- */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * AuthMethodBase is the abstract base class for authentication methods&lt;br /&gt;
**/&lt;br /&gt;
abstract class AuthMethodBase extends FreeDESK_PIM&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * AuthMethodBase Constructor&lt;br /&gt;
	 * @param mixed $freeDESK FreeDESK instance&lt;br /&gt;
	**/&lt;br /&gt;
	function AuthMethodBase(&amp;amp;$freeDESK)&lt;br /&gt;
	{&lt;br /&gt;
		parent::FreeDESK_PIM(&amp;amp;$freeDESK, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, 0);&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Authenticate a user/customer session&lt;br /&gt;
	 * @param int $type Type of Context (ContextType)&lt;br /&gt;
	 * @param string $username Username provided&lt;br /&gt;
	 * @param string $password Password provided&lt;br /&gt;
	 * @return bool True on success or false on failure&lt;br /&gt;
	**/&lt;br /&gt;
	abstract function Authenticate($type, $username, $password);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inbuilt Standard Authentication ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php &lt;br /&gt;
/* -------------------------------------------------------------&lt;br /&gt;
This file is part of FreeDESK&lt;br /&gt;
&lt;br /&gt;
FreeDESK is (C) Copyright 2012 David Cutting&lt;br /&gt;
&lt;br /&gt;
FreeDESK is free software: you can redistribute it and/or modify&lt;br /&gt;
it under the terms of the GNU General Public License as published by&lt;br /&gt;
the Free Software Foundation, either version 3 of the License, or&lt;br /&gt;
(at your option) any later version.&lt;br /&gt;
&lt;br /&gt;
FreeDESK is distributed in the hope that it will be useful,&lt;br /&gt;
but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
You should have received a copy of the GNU General Public License&lt;br /&gt;
along with FreeDESK.  If not, see www.gnu.org/licenses&lt;br /&gt;
&lt;br /&gt;
For more information see www.purplepixie.org/freedesk/&lt;br /&gt;
-------------------------------------------------------------- */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * AuthMethodStandard is the standard (database-based) authentication method&lt;br /&gt;
**/&lt;br /&gt;
class AuthMethodStandard extends AuthMethodBase&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * AuthMethodStandard Constructor&lt;br /&gt;
	 * @param mixed $freeDESK FreeDESK instance&lt;br /&gt;
	**/&lt;br /&gt;
	function AuthMethodStandard(&amp;amp;$freeDESK)&lt;br /&gt;
	{&lt;br /&gt;
		parent::AuthMethodBase($freeDESK);&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Authenticate a user/customer session&lt;br /&gt;
	 * @param int $type Type of Context (ContextType)&lt;br /&gt;
	 * @param string $username Username provided&lt;br /&gt;
	 * @param string $password Password provided&lt;br /&gt;
	 * @return bool True on success or false on failure&lt;br /&gt;
	**/&lt;br /&gt;
	function Authenticate($type, $username, $password)&lt;br /&gt;
	{&lt;br /&gt;
		$valid=false; // default to failed&lt;br /&gt;
	&lt;br /&gt;
		if ($type == ContextType::User)&lt;br /&gt;
		{&lt;br /&gt;
			$password=$this-&amp;gt;DESK-&amp;gt;BaseConfig-&amp;gt;pwd_Hash.$password; // add the hash to the password&lt;br /&gt;
			$q=&amp;quot;SELECT * FROM &amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Table(&amp;quot;user&amp;quot;).&amp;quot; WHERE &amp;quot;;&lt;br /&gt;
			$q.=$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Field(&amp;quot;username&amp;quot;).&amp;quot;=\&amp;quot;&amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Safe($username).&amp;quot;\&amp;quot; AND &amp;quot;;&lt;br /&gt;
			$q.=$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Field(&amp;quot;password&amp;quot;).&amp;quot;=MD5(\&amp;quot;&amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Safe($password).&amp;quot;\&amp;quot;) &amp;quot;;&lt;br /&gt;
			$q.=&amp;quot;LIMIT 0,1&amp;quot;;&lt;br /&gt;
			&lt;br /&gt;
			$r=$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Query($q);&lt;br /&gt;
			&lt;br /&gt;
			if ($user = $this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;FetchAssoc($r))&lt;br /&gt;
				$valid=true;&lt;br /&gt;
			&lt;br /&gt;
			$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Free($r);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// TODO: Customer Authentication&lt;br /&gt;
		&lt;br /&gt;
		return $valid;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Set a standard user password - note no security here and that this is NOT a AutoMethodBase overrided function&lt;br /&gt;
	 * @param string $username Username&lt;br /&gt;
	 * @param string $password Password&lt;br /&gt;
	**/&lt;br /&gt;
	function SetPassword($username, $password)&lt;br /&gt;
	{&lt;br /&gt;
		$password=$this-&amp;gt;DESK-&amp;gt;BaseConfig-&amp;gt;pwd_Hash.$password;&lt;br /&gt;
		$q=&amp;quot;UPDATE &amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Table(&amp;quot;user&amp;quot;).&amp;quot; SET &amp;quot;;&lt;br /&gt;
		$q.=$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Field(&amp;quot;password&amp;quot;).&amp;quot;=MD5(\&amp;quot;&amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Safe($password).&amp;quot;\&amp;quot;) &amp;quot;;&lt;br /&gt;
		$q.=&amp;quot;WHERE &amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Field(&amp;quot;username&amp;quot;).&amp;quot;=\&amp;quot;&amp;quot;.$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Safe($username).&amp;quot;\&amp;quot;&amp;quot;;&lt;br /&gt;
		$this-&amp;gt;DESK-&amp;gt;Database-&amp;gt;Query($q);&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Exec function (static)&lt;br /&gt;
	 * @param mixed $DESK Current FreeDESK instance&lt;br /&gt;
	**/&lt;br /&gt;
	static function Exec(&amp;amp;$DESK)&lt;br /&gt;
	{&lt;br /&gt;
		$plugin = new Plugin();&lt;br /&gt;
		$plugin-&amp;gt;name=&amp;quot;Standard Authentication&amp;quot;;&lt;br /&gt;
		$plugin-&amp;gt;version=&amp;quot;0.01&amp;quot;;&lt;br /&gt;
		$plugin-&amp;gt;type=&amp;quot;Auth&amp;quot;;&lt;br /&gt;
		$plugin-&amp;gt;subtype=&amp;quot;standard&amp;quot;;&lt;br /&gt;
		$plugin-&amp;gt;classname=&amp;quot;AuthMethodStandard&amp;quot;;&lt;br /&gt;
		$DESK-&amp;gt;PluginManager-&amp;gt;Register($plugin);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dave</name></author>	</entry>

	</feed>