开发者

Apache Digest/Basic Login Through PHP

I'm trying to figure out if there is a way to get PHP to log into Apache for a user. So if the user supplies a valid username and password on an HTML form, PHP would login with credentials. So, something like:

<?php 
if ($_POST["user"] == "john" && $_POST["pass"] == "swordfish"){
   apache_login($_POST["user"], $_POST["pass"]);
}
?>

What I'm trying to do is have some kind of login security on Apache in order to protect files but I want to avoid having that username/password pop up that Apache uses to get the credentials.

I want them to fill in their info in an HTML form and have PHP take care of the authentication before they can view any files, that way someone开发者_JAVA百科 can't just put "http://example.com/files/private.doc" in the url and get a file.

Thanks in advance!


Have you tried http://comp.uark.edu/~ajarthu/mod_auth_form/ This adds form-based login for basic authentication. The author states that Apache will have a native capability for this in v2.4 (see https://httpd.apache.org/docs/2.4/mod/mod_auth_form.html)


Read about the Apache Request Processing Model.

Security comes before Handler, the latter of which is where PHP is invoked. If Apache requires authentication for a specific resource requested by a client, this requirement must be fulfilled before the PHP handler is invoked.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜