mod_authn_core
描述: | 核心认证 |
状态: | Base |
模块标识符: | authn_core_module |
源文件: | mod_authn_core.c |
兼容性: | 可在 Apache 2.3 及更高版本中使用 |
摘要
此模块提供核心身份验证功能,以允许或拒绝访问 web 站点的某些部分。mod_authn_core为所有身份验证提供程序提供 common 指令。
创建身份验证提供程序别名
可以在 configuration 文件中创建扩展身份验证提供程序,并为其分配别名 name。然后,可以通过指令AuthBasicProvider或AuthDigestProvider 指令以与基本身份验证提供程序相同的方式引用别名提供程序。除了能够为扩展提供程序创建和别名外,它还允许同一个扩展身份验证提供程序由多个位置进行 reference。
例子
此 example 检查两个不同文本 files 中的密码。
检查多个文本密码 files
# Check here first <AuthnProviderAlias file file1> AuthUserFile "/www/conf/passwords1" </AuthnProviderAlias> # Then check here <AuthnProviderAlias file file2> AuthUserFile "/www/conf/passwords2" </AuthnProviderAlias> <Directory "/var/web/pages/secure"> AuthBasicProvider file1 file2 AuthType Basic AuthName "Protected Area" Require valid-user </Directory>
下面的 example 根据 ldap 提供程序创建两个不同的 ldap 身份验证提供程序别名。这允许多个 ldap 主机为单个经过身份验证的位置提供服务:
检查多个 LDAP 服务器
<AuthnProviderAlias ldap ldap-alias1> AuthLDAPBindDN cn=youruser,o=ctx AuthLDAPBindPassword yourpassword AuthLDAPURL ldap://ldap.host/o=ctx </AuthnProviderAlias> <AuthnProviderAlias ldap ldap-other-alias> AuthLDAPBindDN cn=yourotheruser,o=dev AuthLDAPBindPassword yourotherpassword AuthLDAPURL ldap://other.ldap.host/o=dev?cn </AuthnProviderAlias> Alias "/secure" "/webpages/secure" <Directory "/webpages/secure"> AuthBasicProvider ldap-other-alias ldap-alias1 AuthType Basic AuthName "LDAP Protected Place" Require valid-user # Note that Require ldap-* would not work here, since the # AuthnProviderAlias does not provide the config to authorization providers # that are implemented in the same module as the authentication provider. </Directory>
AuthName 指令
描述: | 授权领域,用于 HTTP 身份验证 |
句法: | AuthName auth-domain |
Context: | 目录,.htaccess |
覆盖: | AuthConfig |
状态: | Base |
模块: | mod_authn_core |
该指令设置目录的授权域的 name。这个领域被赋予 client,以便用户知道要发送的用户名和密码。AuthName
只有一个参数;如果域 name 包含空格,则必须用引号括起来。它必须伴随进行 AuthType和要求指令,并且AuthUserFile和目录 AuthGroupFile等指令才能工作。
例如:
AuthName "Top Secret"
为AuthName
提供的 string 将出现在大多数浏览器提供的密码对话框中。
参见
- 身份验证,授权和访问控制
- mod_authz_core
<AuthnProviderAlias>指令
描述: | 附上一组指令,这些指令表示基本身份验证提供程序的扩展,并由指定的别名引用 |
句法: | <AuthnProviderAlias baseProvider Alias>...</AuthnProviderAlias> |
Context: | 服务器配置 |
状态: | Base |
模块: | mod_authn_core |
<AuthnProviderAlias>
和</AuthnProviderAlias>
用于包含一组身份验证指令,可以使用其中一个指令AuthBasicProvider或AuthDigestProvider 指令由别名 name 引用。
即使对于同时提供身份验证和授权的模块,此指令也不会影响授权。
AuthType 指令
描述: | 用户身份验证的类型 |
句法: | AuthType None\|Basic\|Digest\|Form |
Context: | 目录,.htaccess |
覆盖: | AuthConfig |
状态: | Base |
模块: | mod_authn_core |
该指令选择目录的用户身份验证类型。可用的身份验证类型是None
,Basic
(由mod_auth_basic实现),Digest
(由mod_auth_digest实现)和Form
(由mod_auth_form实现)。
要实现身份验证,还必须使用AuthName 指令和要求指令。此外,服务器必须具有模块(如mod_authn_file)和授权模块(如mod_authz_user)。
身份验证类型None
禁用身份验证。启用身份验证后,除非指定了不同的身份验证类型,否则它通常由每个后续configuration 部分继承。如果对经过身份验证的部分的子部分不需要身份验证,则可以使用身份验证类型None
;在下面的示例中,clients 可以在不进行身份验证的情况下访问/www/docs/public
目录:
<Directory "/www/docs"> AuthType Basic AuthName Documents AuthBasicProvider file AuthUserFile "/usr/local/apache/passwd/passwords" Require valid-user </Directory> <Directory "/www/docs/public"> AuthType None Require all granted </Directory>
禁用身份验证时,请注意已经针对服务器文档树的另一部分进行身份验证的客户端通常会继续向每个请求发送身份验证 HTTP headers 或 cookies,无论服务器是否实际需要对每个资源进行身份验证。
参见
- 身份验证,授权和访问控制