[thelist] looking for good php auth/perm class
Rob Agar
robagar at westnet.com.au
Wed Feb 22 02:22:22 CST 2006
have you checked out PEAR::Auth? http://pear.php.net/package/Auth/
Rob
sbeam wrote:
> 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
>
>
More information about the thelist
mailing list