From: Bradley Nicholes
The module
The modules
The
The
AuthName "By Invitation Only"
+ AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
AuthGroupFile /usr/local/apache/passwd/groups
Require group GroupName
@@ -321,31 +330,42 @@ do?
other than who they are. Something such as where they are
coming from.
The
The usage of these directives is:
+The authorization providers
The usage of these providers is specified through the
+
where address is an IP address (or a partial IP - address) or a fully qualified domain name (or a partial domain - name); you may provide multiple addresses or domain names, if - desired.
+ address) or: + +where domain_name is a fully qualified domain name + (or a partial domain name); you may provide multiple addresses or + domain names, if desired.
For example, if you have someone spamming your message board, and you want to keep them out, you could do the following:
Visitors coming from that address will not be able to see @@ -353,34 +373,62 @@ do? machine name, rather than an IP address, you can use that.
And, if you'd like to block access from an entire domain, you can specify just part of an address or domain name:
Using
Using the
The above example uses the
+ if ((user == "John") ||
+ ((Group == "admin") && (ldap-group <ldap-object> contains auth'ed_user) &&
+ ((ldap-attribute dept == "sales") ||
+ (file-group contains contains auth'ed_user))))
+ then
+ auth_granted
+ else
+ auth_denied
+
Listing just the
This directive sets the name of the authorization realm for a
- directory. This realm is given to the client so that the user
- knows which username and password to send.
-
For example:
- -The string provided for the AuthName
is what will
- appear in the password dialog provided by most browsers.
This directive selects the type of user authentication for a
- directory. The authentication types available are
- Basic
(implemented by
- Digest
- (implemented by
To implement authentication, you must also use the
This directive selects which authenticated users can access a
- resource. The restrictions are processed by authorization
- modules. Some of the allowed syntaxes provided by
-
Require user userid [userid]
- ...
Require group group-name [group-name]
- ...
Require valid-user
Other authorization modules that implement require options
- include
Access controls which are applied in this way are effective for
- all methods. This is what is normally
- desired. If you wish to apply access controls only to
- specific methods, while leaving other methods unprotected, then
- place the
If
The following example shows how to use the
Access policy if both All
or Any
. This directive is only
- useful if access to a particular area is being restricted by both
- username/password and client host address. In this case
- the default behavior (All
) is to require that the client
- passes the address access restriction and enters a valid
- username and password. With the Any
option the client will be
- granted access if they either pass the host restriction or enter a
- valid username and password. This can be used to password restrict
- an area, but to let clients from particular addresses in without
- prompting for a password.
For example, if you wanted to let people on your network have - unrestricted access to a portion of your website, but require that - people outside of your network provide a password, you could use a - configuration similar to the following:
- -Since version 2.0.51
This module provides core authentication capabilities to
+ allow or deny access to portions of the web site.
+
This directive sets the name of the authorization realm for a
+ directory. This realm is given to the client so that the user
+ knows which username and password to send.
+
For example:
+ +The string provided for the AuthName
is what will
+ appear in the password dialog provided by most browsers.
This directive selects the type of user authentication for a
+ directory. The authentication types available are
+ Basic
(implemented by
+ Digest
+ (implemented by
To implement authentication, you must also use the
This module provides core authorization capabilities so that
+ authenticated users can be allowed or denied access to portions
+ of the web site.
This directive selects which authenticated users can access a
+ resource. The restrictions are processed by authorization
+ modules. Some of the allowed syntaxes provided by
+
Require user userid [userid]
+ ...
Require group group-name [group-name]
+ ...
Require valid-user
Other authorization modules that implement require options
+ include
For a complete authentication and authorization configuration,
+
Access controls which are applied in this way are effective for
+ all methods. This is what is normally
+ desired. If you wish to apply access controls only to
+ specific methods, while leaving other methods unprotected, then
+ place the
This directive is similar to the
+
</RequireAll>
are used to enclose a group of
+ authorization directives that must all be satisfied in order to
+ grant access to a resource.
The
+ if ((user == "John") ||
+ ((Group == "admin") && (ldap-group <ldap-object> contains auth'ed_user) &&
+ ((ldap-attribute dept == "sales") ||
+ (file-group contains contains auth'ed_user))))
+ then
+ auth_granted
+ else
+ auth_denied
+
</RequireOne>
are used to enclose a group of
+ authorization directives that must satisfy at least one in order to
+ grant access to a resource.
See the
The directives provided by
The authorization providers implemented by .htaccess
files to control access to particular parts of the server.
Access can be controlled based on the client hostname, IP address, or
other characteristics of the client request, as captured in environment variables. The
Both host-based access restrictions and password-based
- authentication may be implemented simultaneously. In that case,
- the
In general, access restriction directives apply to all
access methods (GET
, PUT
,
@@ -62,111 +52,33 @@ address)
in a
The Apache's These authorization providers affect which hosts can
access an area of the server. Access can be controlled by
hostname, IP Address, IP Address range, or by other
characteristics of the client request captured in environment
variables. The first argument to this directive is always
- Hosts whose names match, or end in, this string are allowed
- access. Only complete components are matched, so the above
- example will match An IP address of a host allowed access The first 1 to 3 bytes of an IP address, for subnet
- restriction. A network a.b.c.d, and a netmask w.x.y.z. For more
- fine-grained subnet restriction. Similar to the previous case, except the netmask consists of
- nnn high-order 1 bits. Note that the last three examples above match exactly the
- same set of hosts. IPv6 addresses and IPv6 subnets can be specified as shown
- below: The third format of the arguments to the
- The In this case, browsers with a user-agent string beginning
with env
, ip
,
+ host
and all
. Other authorization types may also be
+ used but may require that additional authorization modules be loaded.from
. The subsequent arguments can take three
- different forms. If Allow from all
is specified, then
- all hosts are allowed access, subject to the configuration of the
-
-
-
-
- Allow from .net example.edu
- foo.apache.org
but it will not
- match fooapache.org
. This configuration will cause
- Apache to perform a double reverse DNS lookup on the client IP
- address, regardless of the setting of the
- Allow from 192.168.1.104 192.168.1.205
-
- Allow from 10 172.20 192.168.2
-
- Allow from 2001:db8::a00:20ff:fea7:ccea/10
- env
provider allows access to the server
to be controlled based on the existence of an environment variable. When Allow from
- env=env-variable
is specified, then the request is
+ href="../env.html">environment variable. When Require
+ env env-variable
is specified, then the request is
allowed access if the environment variable env-variable
exists. The server provides the ability to set environment
variables in a flexible way based on characteristics of the client
@@ -175,162 +87,126 @@ server
used to allow access based on such factors as the clients
User-Agent
(browser type), Referer
, or
other HTTP request header fields.
<Directory /docroot>
- Deny from all
- Allow from env=let_me_in
+ Require env let_me_in
KnockKnock/2.0
will be allowed access, and all
others will be denied.
This directive allows access to the server to be restricted
- based on hostname, IP address, or environment variables. The
- arguments for the
The
Deny,Allow
Allow,Deny
Mutual-failure
Order
- Allow,Deny
and is deprecated in favor of that
- configuration.Keywords may only be separated by a comma; no whitespace is
- allowed between them. Note that in all cases every
In the following example, all hosts in the apache.org domain - are allowed access; all other hosts are denied access.
+The ip
provider allows access to the server
+ to be controlled based on the IP address of the remote client.
+ When Require ip ip-address
is specified,
+ then the request is allowed access if the IP address matches.
A full IP address:
+In the next example, all hosts in the apache.org domain are - allowed access, except for the hosts which are in the - foo.apache.org subdomain, who are denied access. All hosts not - in the apache.org domain are denied access because the default - state is to deny access to the server.
+An IP address of a host allowed access
+ +A partial IP address:
+ +The first 1 to 3 bytes of an IP address, for subnet + restriction.
+ +A network/netmask pair:
+ +A network a.b.c.d, and a netmask w.x.y.z. For more + fine-grained subnet restriction.
+ +A network/nnn CIDR specification:
+ +Similar to the previous case, except the netmask consists of + nnn high-order 1 bits.
+ +Note that the last three examples above match exactly the + same set of hosts.
+ +IPv6 addresses and IPv6 subnets can be specified as shown + below:
+ +The host
provider allows access to the server
+ to be controlled based on the host name of the remote client.
+ When Require host host-name
is specified,
+ then the request is allowed access if the host name matches.
A (partial) domain-name
+Hosts whose names match, or end in, this string are allowed
+ access. Only complete components are matched, so the above
+ example will match foo.apache.org
but it will not
+ match fooapache.org
. This configuration will cause
+ Apache to perform a double reverse DNS lookup on the client IP
+ address, regardless of the setting of the
The all
provider mimics the functionality the
+ was previously provided by the 'Allow from all' and 'Deny from all'
+ directives. This provider can take one of two arguments which are
+ 'granted' or 'denied'. The following examples will grant or deny
+ access to all requests.
On the other hand, if the Deny,Allow
, all hosts will
- be allowed access. This happens because, regardless of the
- actual ordering of the directives in the configuration file,
- the Allow from apache.org
will be evaluated last
- and will override the Deny from foo.apache.org
.
- All hosts not in the apache.org
domain will also
- be allowed access because the default state will change to
- allow.
The presence of an
will deny all access to the /www
directory
- because the default access state will be set to
- deny.
The .htaccess
file, regardless of the setting of the
-