大网数据广告活动
服务器运维问答

Basic Auth User Management

· 52CE 我爱测

I have 2 questions regarding Apache Basic Auth that i currently am utilising. I have a website that after a certain action, the website will produce a Basic Auth username and password for the user to use to access a service. This…

问题原文

原帖链接 · Tom Burman · CC BY-SA 3.0

I have 2 questions regarding Apache Basic Auth that i currently am utilising. I have a website that after a certain action, the website will produce a Basic Auth username and password for the user to use to access a service.

This is working OK at the moment - but the website is picking up traffic rapidly so there are many many entries in the basic auth file now.

Question 1) Is there a limit on the amount of basic auth users apache can handle?

Question 2) is there a better way to manage basic auth users? Or some type of username/password access

Thanks

已采纳解答

原帖链接 · Pedro Lobito · CC BY-SA 3.0

Is there a limit on the amount of basic auth users apache can handle?

No, You can have as much values as you want inside .htpasswd but with time your server performance will suffer due to high disk I/O reads.

is there a better way to manage basic auth users?

Yes, use a mysql db to store the user/pass and access it with mod_authn_dbd.
Alternatively, you can use php to "emulate" HTTP authentication and query a db with the login info i.e.:

<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
} else {
    //place the query logic here
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。