开发者

Debugging a Browser Redirect Loop

开发者 https://www.devze.com 2022-12-22 12:47 出处:网络
I am using CakePHP with the Auth and ACL components.My page loads fine for non-registe开发者_如何学Gored users, but if I try to log in as a registered user I get an infinite redirect loop in the brows

I am using CakePHP with the Auth and ACL components. My page loads fine for non-registe开发者_如何学Gored users, but if I try to log in as a registered user I get an infinite redirect loop in the browser.

I am sure that this is some sort of permissions problem, but the problem exists even for users who have permissions for everything. The only way to prevent this behavior is to allow '*' in my AppController's beforeFilter method.

What is the best way to debug this sort of problem?

Thanks!


For debugging purposes, try inserting this first thing in your AppController::beforeFilter():

$this->log("Here: {$this->here}, coming from: " . $this->referer(), LOG_DEBUG);

This will write to the log in /app/tmp/logs/debug.log. You could also combine this with overriding the redirect method in the AppController:

function redirect($url, $status = null, $exit = true) {
    $trace = debug_backtrace();
    $this->log("Redirecting to: " . Router::url($url) . ", initiated in {$trace[1]['file']} on line {$trace[1]['line']}", LOG_DEBUG);
    parent::redirect($url, $status, $exit);
}


Also ensure that you check over the settings of your Auth component in your app_controller are setup correctly.

http://book.cakephp.org/1.3/en/The-Manual/Core-Components/Authentication.html#setting-auth-component-variables

I tend to explicitly define them all. Maybe check over something like this, http://www.webdevelopment2.com/cakephp-auth-component-tutorial-1/ Just to be certain it's all setup correctly.

The other thing that I found is occasionally, beforeFilter() can sometimes knockout the setup of Auth in your app_controller, so maybe try in your controllers having

parent::beforeFilter();

To ensure that your app_controller's beforeFilter() is being executed.


The first thing I would check is the login method of the Users controller. If implemented correctly, you will typically route all un verified/authorized traffic to the login controller. However, if you have not given permission to the public, it will most likely result in an infinite loop. So check the app_controller (or wherever you are storing the Auth/ACL permissions) and make sure that Users.login is publicly accessible.

0

精彩评论

暂无评论...
验证码 换一张
取 消