Since the username and password are so trivially protected in the
Basic authentication mechanism, the same authentication database can
be used to store user information for multiple realms. The
Digest mechanism, though, includes an encoding of the realm for
which the credentials are valid, so you must have a separate
credentials database for each realm using the Digest method.
When setting up discretionary controls in your Apache configuration,
remember that the AuthType
directive is
required. The setting can be inherited from a higher-level
directory or location, but something must set the value to be
inherited; there is no default.
Satisfy
Directive Sometimes you want to mix and match discretionary and non-discretionary
access controls, such as allowing anyone on the local network to
see documents freely, but requiring anyone else to enter a username
and password.
This can be done with the Satisfy
directive, which takes
a single keyword:
All
Satisfy All
directive, a client mustAllow
or Deny
directives) andRequire
directives).Any
Satisfy Any
To illustrate, the following would permit any client on the
local network (IP addresses 10.*.*.*) to access the foo.html
page without let or hindrance, but require a username and password
for anyone else:
Order Deny,Allow Deny from All Allow from 10.0.0.0/255.0.0.0 AuthName "Insiders Only" AuthType Basic AuthUserFile /usr/local/web/apache/.htpasswd-foo Require valid-user Satisfy AnyRestricting by IP Address
Since the IP address is one of those aspects of a client-server
HTTP relationship that cannot be changed mid-stream, and cannot
be easily faked (without the cooperation of the intervening
network systems), it's considered a non-discretionary control.
The Apache distribution includes a module for limiting access
thusly, calledmod_access
.
mod_access
allows you to specify what domains
or addresses should or should not be allowed access, and in which order
the two lists (allowed and denied) should be evaluated. The basic
syntax of theAllow
andDeny
directives isAllow from host-or-networkThe
host-or-network
can be:
www.foo.com
),10.0.72.3
),10.0.0.0/255.0.0.0
), or10.73.128.0/18
)Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.