[thelist] looking for good php auth/perm class

sbeam sbeam at onsetcorps.net
Tue Feb 21 20:00:04 CST 2006


Does anyone know of any quality PHP classes/frameworks that specialize 
in session-based authentication, permissions management, etc.? I am 
thinking of something that has the following attributes:

* can "password protect" any page with 1-2 lines of code
* can be extended to get user/perm data from any DB, LDAP, SOAP whatever
* works well with php5
* does hierarchical and exclusive permissions levels easily
* does not come with bells, whistles
* is secure in every way (obviously)

Ideally the calling code for this would look something like this:

myMagicAuth::requirePerm('editor'); // restrict to editors and above

and the local class for this might look something like

class myMagicAuth extends magicAuth {
  static $perms = array('guest'=>1, 'editor'=>2, 
                        'admin'=>4, 'superuser'=>7);
  static function requirePerm ($need_perm) 
  {
    $perm = self::$perms[$need_perm];
    $user = magicUser::getUserSingleton(); // inst. user from session?    
    if (!($user->getPerm() & $perm)) {
       magicAuth::requestCredentials(); // shows the login form
       exit();   
    }
  }
}

of course there would be a lot more to it. In case you are wondering I 
am thinking about (re)writing something like the above but don't want 
to reinvent the wheel. I know I could go to phpclasses.org et al. but 
the quality there is abysmal usually. Someone must have tackled this 
common problem before....

thanks


-- 

# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/



More information about the thelist mailing list