简体   繁体   English

laravel Redirect :: intention()重定向到完整的URL

[英]laravel Redirect::intended() redirects to the full URL

I'm using a custom Auth driver for Laravel 4 that needs to redirect back to whatever page triggered the authentication process. 我正在为Laravel 4使用自定义Auth驱动程序,需要重定向回到触发身份验证过程的任何页面。 The driver drops the user out to a single sign-on service on a completely different domain, then back again once their service had signed the user in. All of that works fine right up until the first time the user is returned from the SSO server. 驱动程序将用户退出到完全不同的域上的单一登录服务,然后在其服务已对用户进行签名后再次返回。所有这些工作正常,直到第一次从SSO服务器返回用户。 I'm using a return Redirect::intended(); 我正在使用return Redirect::intended(); statement to get back to where the user needs to be, but rather than accessing http://www.some.dev/secret and being redirected to the same, the user is being redirected to http://www.some.dev/http://www.some.dev/secret which, naturally, doesn't quite work properly. 声明回到用户需要的位置,而不是访问http://www.some.dev/secret并重定向到相同的用户,该用户被重定向到http://www.some.dev/http://www.some.dev/secret ,当然,它不能正常工作。 I chased down how Laravel stores the REQUEST_URI session variable, and it seems to pull the full URL. 我追查了Laravel如何存储REQUEST_URI会话变量,它似乎拉出了完整的URL。 Not sure how other people don't end up redirected incorrectly, but I'm curious if anyone has faced this and if so, how you fixed it, whether it was a bad configuration file or tweaking the framework. 不确定其他人如何不会错误地重定向,但我很好奇是否有人遇到过这种情况,如果有的话,你是如何修复它的,无论是错误的配置文件还是调整框架。

eta : in the 404 stack trace, Laravel says the REQUEST_URI value is set to /http://www.some.dev/secret . eta :在404堆栈跟踪中,Laravel说REQUEST_URI值设置为/http://www.some.dev/secret So it seems not to be an .htaccess goof. 所以似乎不是一个.htaccess蠢事。

eta2 : tested my route two ways: eta2 :用两种方式测试我的路线:

Route::get('secret', array('before' => 'auth', 'uses' => 'ExampleController@phpinfo'));

and

Route::get('/secret', array('before' => 'auth', 'uses' => 'ExampleController@phpinfo'));

No difference. 没有不同。

eta3 : I'm just going to keep adding stuff. eta3 :我只是要继续添加内容。 So this behavior only occurs when I log out of Eloquent (but not SSO), and even then only the first time I go to the page. 所以这种行为只发生在我退出Eloquent(但不是SSO)时,即使那时我才第一次去页面。 So let's say the very first time, I'm not signed in to SSO or Eloquent. 所以,让我们说第一次,我没有登录SSO或Eloquent。 I sign on through SSO, which then logs me in internally through Eloquent. 我通过SSO登录,然后通过Eloquent在内部登录。 I get the wrong REQUEST_URI . 我得错了REQUEST_URI I go back to the address bar, ditch the stuff behind http://www.some.dev/ and type secret back in (browsing straight to http://www.some.dev/secret ). 我回到地址栏,抛弃http://www.some.dev/后面的东西并输入secret (直接浏览到http://www.some.dev/secret )。 I get to the page without any problem. 我没有任何问题到达页面。 On my page is a logout link that clears the Eloquent credentials. 在我的页面上有一个注销链接,用于清除Eloquent凭据。 I also echoed $_SERVER['REQUEST_URI'] at the bottom of the page, and I see it's /secret . 我还在页面底部回显了$_SERVER['REQUEST_URI'] ,我看到它/secret I click the logout button, which clears Eloquent credentials but keeps SSO credentials alive. 我单击注销按钮,清除Eloquent凭据但保持SSO凭证存活。 I browse back to /secret and I see the same nonsense REQUEST_URI . 我浏览回到/secret ,我看到同样的废话REQUEST_URI Clear, enter secret again, and I'm fine. 清楚,再次进入secret ,我很好。 So it seems that when I'm re-validating my Eloquent credentials with Auth::login it's messing up my REQUEST_URI . 所以当我用Auth::login重新验证我的Eloquent凭证时,它似乎弄乱了我的REQUEST_URI Could that be because I'm bouncing credentials off a different domain, so the framework had to convert a relative URL into a static one? 可能是因为我在不同的域上弹出凭据,所以框架必须将相对URL转换为静态URL?

我怀疑你首先传递给SSO服务器的redirectBackTo URL是不正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM