简体   繁体   English

PHP中的外部HTTP身份验证

[英]External HTTP Authentication in PHP

Looking to redirect to my university's login page in order to authenticate users with $_SERVER['REMOTE_USER']. 希望重定向到我大学的登录页面,以便使用$ _SERVER ['REMOTE_USER']对用户进行身份验证。 Conventionally, I would use an htaccess file to redirect to the login page, but I would like my solution to be completely in PHP. 传统上,我会使用htaccess文件重定向到登录页面,但我希望我的解决方案完全在PHP中。 I imagine the start would be... 我想起初会......

header('Location:http://login.university.edu');

But I would need to specify the return url, correct? 但我需要指定返回网址,对吗? I don't know. 我不知道。 I may be completely wrong about this. 我可能完全错了。 Any help appreciated. 任何帮助赞赏。

Careful: 小心:

header('Location: http://login.university.edu');
                 ^ space

iirc Header("Location ...") can't specify a query string. iirc Header(“Location ...”)无法指定查询字符串。

You can use a meta refresh tag of 1 second. 您可以使用1秒的元刷新标记。

What authentication system does your university use? 你的大学使用什么认证系统?

This is not possible in PHP or any other language. 这在PHP或任何其他语言中是不可能的。 It would have to be implemented on your university's system. 它必须在您大学的系统上实施。 Most university login systems (especially for WiFi login) allow you to add a return url, but you'll need to ask what the name of this parameter is. 大多数大学登录系统(特别是WiFi登录)允许您添加返回URL,但您需要询问此参数的名称是什么。 My guess would be: 我的猜测是:

header('Location: http://login.university.edu?return='+urlencode('http://www.mysite.com/page.php'));

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

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