©
This document usesPHP Chinese website manualRelease
说明 | 基于文件的所有者进行授权 |
---|---|
状态 | 扩展(E) |
模块名 | authz_owner_module |
源文件 | mod_authz_owner.c |
兼容性 | 仅在 Apache 2.1 及以后的版本中可用 |
This module authorizes access to files by comparing the userid used for HTTP authentication (the web userid) with the file-system owner or group of the requested file. The supplied username and password must be already properly verified by an authentication module, such asmod_auth_basic
或mod_auth_digest
.mod_authz_owner
recognizes two arguments for theRequire
directive,file-owner
和file-group
, as follows:
file-owner
jones
, then the username used to access it through the web must be
jones
as well.
file-group
mod_authz_groupfile
或
mod_authz_dbm
, and the web-username must be a member of that group. For example, if the operating system says the requested file is owned by (system) group
accounts
, the group
accounts
must appear in the group database and the web-username used in the request must be a member of that group.
Ifmod_authz_owner
is used in order to authorize a resource that is not actually present in the filesystem (i.e.a virtual resource), it will deny the access.
Particularly it will never authorize content negotiated "MultiViews" resources.
Consider a multi-user system running the Apache Web server, with each user having his or her own files in~/public_html/private
. Assuming that there is a singleAuthDBMUserFile
database that lists all of their web-usernames, and that these usernames match the system's usernames that actually own the files on the server, then the following stanza would allow only the user himself access to his own files. Userjones
would not be allowed to access files in/home/smith/public_html/private
unless they were owned byjones
instead ofsmith
.
AuthType Basic
AuthName MyPrivateFiles
AuthBasicProvider dbm
AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
Satisfy All
Require file-owner
Consider a system similar to the one described above, but with some users that share their project files in~/public_html/project-foo
. The files are owned by the system groupfoo
and there is a singleAuthDBMGroupFile
database that contains all of the web-usernames and their group membership,i.e.they must be at least member of a group namedfoo
. So ifjones
和smith
are both member of the groupfoo
, then both will be authorized to access theproject-foo
directories of each other.
AuthType Basic
AuthName "Project Foo Files"
AuthBasicProvider dbm
# combined user/group database
AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
AuthDBMGroupFile /usr/local/apache2/etc/.htdbm-all
Satisfy All
Require file-group
说明 | Sets whether authorization will be passed on to lower level modules |
---|---|
语法 | AuthzOwnerAuthoritative On|Off |
默认值 | AuthzOwnerAuthoritative On |
作用域 | directory, .htaccess |
覆盖项 | AuthConfig |
状态 | 扩展(E) |
模块 | mod_authz_owner |
Setting theAuthzOwnerAuthoritative
directive explicitly toOff
allows for user authorization to be passed on to lower level modules (as defined in themodules.c
files) if:
file-owner
the file-system owner does not match the supplied web-username or could not be determined, orfile-group
the file-system group does not contain the supplied web-username or could not be determined.Note that setting the value toOff
also allows the combination offile-owner
和file-group
, so access will be allowed if either one or the other (or both) match.
By default, control is not passed on and an authorization failure will result in an "Authentication Required" reply. Not setting it toOff
thus keeps the system secure and forces an NCSA compliant behaviour.