Re: auth_http

From: Date: Mon, 13 Mar 2006 16:21:36 +0000
Subject: Re: auth_http
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23277@lists.php.net to get a copy of this message
Bonjour, Frank Høvin wrote:
Hi, Are there any hopes of anything happening with the auth_php module? I see there’s a bug posted about problems with logout(). I’ve got the exact same problem myself, and nowhere have I been able to find a sollution. I just can’t get the logout() function to work. As others have specified (not sure if it’s posted in the bug thread) the problem seems to be independent of browser/platform. At least, I’ve tried with Firefox, IE, Opera, Opera for Mac, IE for Mac and Safari, without luck. I also got tipped in the irc channel to offer to help with the bugs, as there hasn’t happened much there for a while. I’d volunteer to help with this, if I knew what I’d have to do :-) ”One of the major reasons for the fall of the Roman empire was that, lacking the number zero, they had no way to effectively terminate their C programs.” I guess you mean: http://pear.php.net/bugs/bug.php?id=3351 ...
I don't use Auth_HTTP, but a simple direct Auth with a HTTP custom loginFunction. (the custom 'Shadow' container is similar to the File_Passwd_Unix, but single script) .... $_POST['username'] = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; $_POST['password'] = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; require_once "Auth/Auth.php"; function loginHeader() { header('WWW-Authenticate: Basic realm="RouteIt"'); header('HTTP/1.0 401 Unauthorized'); echo "<div id=\"news\"><span=\"content\">You must enter a valid login ID and password to access this resource</span></div>"; } $a = new Auth('Shadow', $cfgfiles['pass'], 'loginHeader'); // starting the authentication process $a->start(); // checking for autenticated user if (!$a->checkAuth()) { die($debug.'<html><body><h3>You must be identified to access this page</h3></body></html>'); }; if (isset($_POST['logout'])) { $a->logout(); $_POST['username'] = $_POST['password'] = ''; @$a->start(); die($debug.'<html><body><h3>RouteIt: Session closed</h3></body></html>'); } $username = $a->getUsername(); .... I know, it's quite a hack as I copy $_SERVER['PHP_AUTH_USER'] in $_POST['username'] and $_SERVER['PHP_AUTH_PW'] in $_POST['password'], anyway, that's all I found in this time, I should check the new Pear_Auth to see if that could be done smarter. Anyway, the logout() done this way is working, it looks strange to $a->start() again but the goal is to call back the loginFunction, so the identification headers are sent again. It's inherent to the protocol, a HTTP logout requires to send again the authentification headers. It's not done by the default Auth's logout() which Auth_HTTP uses, why I implemented this "back" start() after logout(). However, it's well known for the HTTP authentification, the browsers will delete the credentials only when the end-user will cancel the login dialog box. So, to logout, the user must: 1) ask to logout (a posted button here) 2) confirm h(er|is) logout by hitting cancel in the identification prompt s?he gets back Then, so far I can check, the logout is effective, any new access tentative necessitate to login again. I use it in some other project and never got any complain. Perhaps a similar solution could be implemented in Auth_HTTP... through the logoutCallback or by overwriting the logout() method. Please correct me if I'm wrong in my analysis. Sorry for this poor english. Regards -- toggg

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