mod_authn_file
描述: | 使用 text files 进行用户身份验证 |
状态: | Base |
模块标识符: | authn_file_module |
源文件: | mod_authn_file.c |
兼容性: | 可在 Apache 2.1 及更高版本中使用 |
摘要
此模块提供身份验证 front-ends,例如mod_auth_digest和mod_auth_basic,通过以纯文本密码 files 查找用户来对用户进行身份验证。mod_authn_dbm提供了类似的功能。
使用mod_auth_basic或mod_auth_digest时,通过带file
value 的AuthBasicProvider或AuthDigestProvider 指令调用此模块。
AuthUserFile 指令
描述: | 设置包含用于身份验证的用户和密码列表的文本文件的 name |
句法: | AuthUserFile file-path |
Context: | 目录,.htaccess |
覆盖: | AuthConfig |
状态: | Base |
模块: | mod_authn_file |
AuthUserFile
指令设置包含用户身份验证的用户和密码列表的文本文件的 name。 File-path 是用户文件的路径。如果它不是绝对的,则将其视为相对于ServerRoot。
用户文件的每个 line 包含一个用户名,后跟一个冒号,后跟加密的密码。如果多次定义相同的用户 ID,mod_authn_file将使用第一次出现来验证密码。
加密的密码格式取决于正在使用的身份验证前端(e.g.mod_auth_basic或mod_auth_digest)。有关更多信息,请参见密码格式。
对于mod_auth_basic,使用实用程序htpasswd,它是作为二进制分发的一部分安装的,或者可以在src/support
中找到。有关详细信息,请参阅手册页。简而言之:
使用username
作为初始 ID 创建密码文件Filename
。它会提示输入密码:
htpasswd -c Filename username
在密码文件Filename
中添加或修改username2
:
htpasswd Filename username2
请注意,搜索大型文本 files 效率非常低;应该使用AuthDBMUserFile代替。
对于mod_auth_digest,请改用htdigest。请注意,您不能在同一文件中混合摘要式身份验证和基本身份验证的用户数据。
安全
确保AuthUserFile
存储在 web-server 的文档树之外。不要**把它放在它保护的目录中。否则,clients 可能能够下载AuthUserFile
。