View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Auth_Adapter_Doctrine_Table
{zone-data}

{zone-data:proposer-list}
[Jason Eisenmenger|mailto:jasoneisen@gmail.com]
[David A. Werner|mailto:vraccas@gmail.com]
{zone-data}

{zone-data:liaison}
[~ralph]
{zone-data}

{zone-data:revision}
1.0 - 16 June 2008: Working Draft.
{zone-data}

{zone-data:overview}
Zend_Auth_Adapter_Doctrine_Table is an authentication adapter for Zend_Auth to use the Doctrine DBAL

You may download the most up-to-date class [here|http://framework.zend.com/wiki/download/attachments/3866950/Table.php].
{zone-data}

{zone-data:references}
* [Zend_Auth_Adapter_Dbtable]
{zone-data}

{zone-data:requirements}
* This component *will* provide the exact same functionality as Zend_Auth_Adapter_DbTable
* This component *will* support Doctrine's query conventions in the adapter methods.
{zone-data}

{zone-data:dependencies}
* Zend_Auth_Adapter_Interface
* Zend_Auth_Result
* Zend_Auth_Adapter_Exception
* Doctrine_Connection_Common
* Doctrine_Query
{zone-data}

{zone-data:operation}
This component is used exactly the same way as Zend_Auth_Adapter_DbTable, with the added functionality of using Doctrine's preferred way of casting names.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Initial proposal published for review with working prototype. (See overview for link)
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_Auth_Adapter_Doctrine_Table
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
 
// Standard drop-in from Zend_DbTable
 
        $authAdapter = new Zend_Auth_Adapter_Doctrine_Table(
            Doctrine::getConnectionByTableName('User'));
        $authAdapter->setTableName('User')
                    ->setIdentityColumn('user_email')
                    ->setCredentialColumn('user_password')
                    ->setCredentialTreatment('md5(?)')
                    ->setIdentity('user')
                    ->setCredential('password');
        $auth = Zend_Auth::getInstance();
        $result = $auth->authenticate($authAdapter);
        if ($result->isValid()) {
            $data = $authAdapter->getResultRowObject('user_id', 'user_password');
            $auth->getStorage()->write($data);
        } else {
            echo "No matching email/password";
        }
}
{code}
||UC-02||
 {code}
        $authAdapter = new Zend_Auth_Adapter_Doctrine_Table(
            Doctrine::getConnectionByTableName('User'));
        $authAdapter->setTableName('User u')
                    ->setIdentityColumn('u.user_email')
                    ->setCredentialColumn('u.user_password')
                    ->setCredentialTreatment('md5(?)')
                    ->setIdentity('user')
                    ->setCredential('password');
        $auth = Zend_Auth::getInstance();
        $result = $auth->authenticate($authAdapter);
        if ($result->isValid()) {
            $data = $authAdapter->getResultRowObject('user_id', 'user_password');
            $auth->getStorage()->write($data);
        } else {
            echo "No matching email/password";
        }
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Auth_Adapter_Doctrine_Table implements Zend_Auth_Adapter_Interface
{
    /**
     * Database Connection
     *
     * @var Zend_Db_Adapter_Abstract
     */
    protected $_conn = null;

    /**
     * $_tableName - the table name to check
     *
     * @var string
     */
    protected $_tableName = null;

    /**
     * $_identityColumn - the column to use as the identity
     *
     * @var string
     */
    protected $_identityColumn = null;

    /**
     * $_credentialColumns - columns to be used as the credentials
     *
     * @var string
     */
    protected $_credentialColumn = null;

    /**
     * $_identity - Identity value
     *
     * @var string
     */
    protected $_identity = null;

    /**
     * $_credential - Credential values
     *
     * @var string
     */
    protected $_credential = null;

    /**
     * $_credentialTreatment - Treatment applied to the credential, such as MD5() or PASSWORD()
     *
     * @var string
     */
    protected $_credentialTreatment = null;

    /**
     * $_authenticateResultInfo
     *
     * @var array
     */
    protected $_authenticateResultInfo = null;
   
    /**
     * $_resultRow - Results of database authentication query
     *
     * @var array
     */
    protected $_resultRow = null;

    /**
     * __construct() - Sets configuration options
     *
     * @param  Zend_Db_Adapter_Abstract $zendDb
     * @param  string                   $tableName
     * @param  string                   $identityColumn
     * @param  string                   $credentialColumn
     * @param  string                   $credentialTreatment
     * @return void
     */
    public function __construct(Doctrine_Connection_Common $conn = null, $tableName = null, $identityColumn = null,
                                $credentialColumn = null, $credentialTreatment = null)
    {
    }

/**
* setConnection() - set the connection to the database
*
* @param Doctrine_Connection_Common $conn
* @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
*/
public function setConnection(Doctrine_Connection_Common $conn)
{
}

/**
* getConnection() - get the connection to the database
*
* @return Doctrine_Connection_Common|null
*/
public function getConnection()
{
}

    /**
     * setTableName() - set the table name to be used in the select query
     *
     * @param  string $tableName
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setTableName($tableName)
    {
    }

    /**
     * setIdentityColumn() - set the column name to be used as the identity column
     *
     * @param  string $identityColumn
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setIdentityColumn($identityColumn)
    {
    }

    /**
     * setCredentialColumn() - set the column name to be used as the credential column
     *
     * @param  string $credentialColumn
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setCredentialColumn($credentialColumn)
    {
    }

    /**
     * setCredentialTreatment() - allows the developer to pass a parameterized string that is
     * used to transform or treat the input credential data
     *
     * In many cases, passwords and other sensitive data are encrypted, hashed, encoded,
     * obscured, or otherwise treated through some function or algorithm. By specifying a
     * parameterized treatment string with this method, a developer may apply arbitrary SQL
     * upon input credential data.
     *
     * Examples:
     *
     *  'PASSWORD(?)'
     *  'MD5(?)'
     *
     * @param  string $treatment
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setCredentialTreatment($treatment)
    {
    }

    /**
     * setIdentity() - set the value to be used as the identity
     *
     * @param  string $value
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setIdentity($value)
    {
    }

    /**
     * setCredential() - set the credential value to be used, optionally can specify a treatment
     * to be used, should be supplied in parameterized form, such as 'MD5(?)' or 'PASSWORD(?)'
     *
     * @param  string $credential
     * @return Zend_Auth_Adapter_Doctrine_Table Provides a fluent interface
     */
    public function setCredential($credential)
    {
    }

    /**
     * getResultRowObject() - Returns the result row as a stdClass object
     *
     * @param  string|array $returnColumns
     * @param  string|array $omitColumns
     * @return stdClass|boolean
     */
    public function getResultRowObject($returnColumns = null, $omitColumns = null)
    {
    }

    /**
     * authenticate() - defined by Zend_Auth_Adapter_Interface.  This method is called to
     * attempt an authentication.  Previous to this call, this adapter would have already
     * been configured with all necessary information to successfully connect to a database
     * table and attempt to find a record matching the provided identity.
     *
     * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
     * @return Zend_Auth_Result
     */
    public function authenticate()
    {
    }

    /**
     * _authenticateSetup() - This method abstracts the steps involved with making sure
     * that this adapter was indeed setup properly with all required peices of information.
     *
     * @throws Zend_Auth_Adapter_Exception - in the event that setup was not done properly
     * @return true
     */
    protected function _authenticateSetup()
    {
    }

    /**
     * _authenticateCreateSelect() - This method creates a Zend_Db_Select object that
     * is completely configured to be queried against the database.
     *
     * @return Doctrine_Query
     */
    protected function _authenticateCreateSelect()
    {
    }

    /**
     * _authenticateQuerySelect() - This method accepts a Doctrine_Query object and
     * performs a query against the database with that object.
     *
     * @param Doctrine_Query $dbSelect
     * @throws Zend_Auth_Adapter_Exception - when a invalid select object is encoutered
     * @return array
     */
    protected function _authenticateQuerySelect(Doctrine_Query $dbSelect)
    {
    }

    /**
     * _authenticateValidateResultSet() - This method attempts to make certian that only one
     * record was returned in the result set
     *
     * @param array $resultIdentities
     * @return true|Zend_Auth_Result
     */
    protected function _authenticateValidateResultSet(array $resultIdentities)
    {
    }

    /**
     * _authenticateValidateResult() - This method attempts to validate that the record in the
     * result set is indeed a record that matched the identity provided to this adapter.
     *
     * @param array $resultIdentity
     * @return Zend_Auth_Result
     */
    protected function _authenticateValidateResult($resultIdentity)
    {
    }
   
    /**
     * _authenticateCreateAuthResult() - This method creates a Zend_Auth_Result object
     * from the information that has been collected during the authenticate() attempt.
     *
     * @return Zend_Auth_Result
     */
    protected function _authenticateCreateAuthResult()
    {
    }

}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>