Re: PEAR::AUTH many problems; idle timeout, multiple logins required; does anyone really use it?

From: Date: Thu, 08 Sep 2005 16:56:26 +0000
Subject: Re: PEAR::AUTH many problems; idle timeout, multiple logins required; does anyone really use it?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20869@lists.php.net to get a copy of this message
On 9/7/05, junkmail <scafmac@gmail.com> wrote: > I have been trying to use the PEAR::Auth package, but have been have a > number of problems. I was wondering if these problems are well known or > not and if so how anyone uses the package. I've searched the mail list > archive, but I haven't found any recent relevant problems. > > I've made sure that both PEAR and Auth are up to date. > > First off, the biggest problem is, after logging in to one restricted > page, the user is required to login a second time if they go to another > restricted page. This doesn't seem right - am I missing something? > Here is the code: > > Page one: > require_once 'myAuth.php'; // defines loginFunction, params, > // & dumpAgent > > $agent = new Auth("DB", $params, "loginFunction"); > echo "<br />Quick check: "; > dumpAgent($agent); > > $agent->start(); > if($agent->checkAuth()){ > blah blah blah... > // form calls page two.php to handle form data > } > > Page two: > require_once 'myAuth.php'; > > // First make sure logged in... > $agent = new Auth("DB", $params, "loginFunction"); > $agent->start(); > > echo "<br />Quick check: "; > dumpAgent($agent); > echo "<br />End quick check "; > > if($agent->checkAuth()){ > // Handle form data from page one > blah blah blah... > } > > So the user is required to login before seeing the form on page one, > then the user is required to login again after submitting the form and > calling page two. Once both pages have been logged in to, the user can > go back and forth without having to login again. What am I missing? Have you tried putting a session_start() before any auto usage in both of these files? Are both of these pages in the same directory? Have you tried tracing into Auth to see where it's failing? When the same kind of thing happened to me it was because the session wasn't being created correctly. Adding a session_start() fixed it for me. If it doesn't work for you please try tracing in (I use "echo") and see where the problem seems to lie. > > Second issue is the idle timeout doesn't seem to work. I've set the > idle timeout limit for 5 minutes, walked away for an hour. After > returning the account has not been idled out, or at least I'm not > required to log back in. Are you refreshing the page with javascript or a meta refresh? If not, are you sure the page isn't being refreshed somehow? I would suggest adding a session value which is incremented every time you visit the page. Let it run for 15 minutes then refresh and see what the # is. > > Finally while trying to debug this problem, I've found what I presume is > a bug. The dumpAgent function I refer to above does a formated dump of > the agent object. It appears that there is a recursive reference to the > agent object in Auth.php on line 198. The line is: > > $this->storage->_auth_obj =& $this; > > If I comment out the line, the recursive self reference disappears, but > it doesn't appear to fix any of my other problems. There is a cryptic > comment above line 198, it is: > > // Pass a reference to auth to the container, ugly but works > // this is used by the DB container to use method setAuthData not > statically. > > Does anyone know what this does? I question the comment about it > working, but it isn't clear to me what it is supposed to be doing. At > the very least it increases the size of the auth object by many, many > factors. This is not a bug, why would you assume it is? The package author put this in for a reason and it will break things if you take it out. And no, this will not increase memory usage by anything mor ethan a pittance. Notice the =& which means it's a *reference* to the current object, not a copy. > > Is the Auth package really used? I've seen PHP security references > recommending using Auth instead of writing ones own because it will be > more secure. I question that seeing as how buggy it appears to be. > Even if I'm misusing it, at the very least the documentation should be > improved so users do not misuse it. Any help? > -- Justin Patrin

« previous php.pear.general (#20869) next »