通过系统帐户在Apache中进行身份validation

我目前有我的apache服务器通过从htpasswd创build的密码文件进行身份validation。 configuration如下:

AuthType Basic AuthName "Secured Site" AuthUserFile "/etc/apache2/users.passwd" 

我怎样才能改变这个通过本地系统帐户进行​​身份validation,并且只限制在指定组中的本地系统帐户的一个子集?

正如David Z所build议的那样,您可以使用mod-authnz-external。 例如与pwauth一起使用它。

如果您正在运行Debian或衍生产品:

 apt-get install libapache2-mod-authnz-external pwauth a2enmod authnz_external 

在你的configuration中,添加

 <IfModule mod_authnz_external.c> AddExternalAuth pwauth /usr/sbin/pwauth SetExternalAuthMethod pwauth pipe </IfModule> 

并在目录部分或您的.htaccess文件中:

  AuthType Basic AuthName "Login" AuthBasicProvider external AuthExternal pwauth Require valid-user # or # Require user jules jim ... 

最后重新加载apache2ctl restartservice apache2 reload

另请参阅此文档 。

你可能想看看像mod_auth_pam 。 PAM是“可插拔authentication模块”系统,标准Linux(我假设这是Linux)系统login机制依靠PAM进行authentication。

另一个选项是mod_authnz_external ,它将直接查看/etc/shadow文件来validation帐户。

编辑 :显然mod_auth_pam不再维护(不幸),所以也许mod_authnz_external将是一个更好的select…

Apache模块mod_auth_pam将为你完成这个工作。 您启用该模块,configuration文件应该看起来像

 AuthType Basic AuthName "secure area" require group staff require user webmaster 

而且你们都定了。