added DooDigestAuth::authWithFunc()
added DooDigestAuth::authWithFunc()

Authenticate using a function/method to process the auth logic. You can use this method to authenticate against a database data.

For HTTP digest auth, password key in by the user in the login dialog cannot be retrieved in plain text. 

Thus, storing of hased password is required, eg.:

<code>
//Hash format
md5($username .':'. $realm .':'. $password)

//Or use this method to generate the hash
DooDigestAuth::hashPassphrase($username, $password, $realm);
</code>

Example usage to authenticate with a database:
First, store the hash in a table.
<code>
  // after creating a user, store this
  // Table: user_realm_hash, Model: UserRealmHash
  // columns: username, realm, hash, user_id 
  $realmHash = new UserRealmHash();
  $realmHash->username = 'admin';
  $realmHash->realm = 'Admin Section';
  $realmHash->hash = DooDigestAuth::hashPassphrase('admin', 'password', 'Admin Section'); 
  $realmHash->insert();        
</code>

To begin the authentication process, put this line in your controller/method where you need to authenticate the user
<code>
// use $this->authUser
class AdminController extends DooController {
     public function manageAll(){
         DooDigestAuth::authWithFunc('Admin Login', array($this, 'authUser'), 'GGGG', null, true);
         //... CRUD code follows ...
     }

     public function authUser( $username, $realm ){
         $u = new UserRealmHash();
         $u->realm = $realm;
         $u->username = $username;
         $u = $u->getOne();
         if($u){
             return $u->hash;
         }
         return null;
     }
</code>

git-svn-id: cc6bf778016782145e08f50c22fd3532de014314@632 eaaf3d48-7251-11de-8585-3f51e31374b7

darkredz/DooPHP,darkredz/DooPHP