Differences between revisions 20 and 21
Revision 20 as of 2009-09-20 22:13:25
Size: 2946
Editor: localhost
Comment: converted to 1.6 markup
Revision 21 as of 2009-10-16 12:18:37
Size: 2948
Editor: noodl
Comment: Fix another code block
Deletions are marked like this. Additions are marked like this.
Line 39: Line 39:
{{{<Directory /home/www/site1/private/noprotect> {{{
<Directory /home/www/site1/private/noprotect>

Bypass Authentication Or Access Requirements

The Satisfy directive controls how Authentication directives (used for password protection) and access directives (e.g. Allow/Deny) interact with each other. You can instruct your Apache server to allow requests if either authentication or access requirements are met. Or you can insist that all criteria are met before allowing the request.

Satisfy comes with two options:

  • Satisfy Any Allows the request if any requirement is met (authentication OR access).

  • Satisfy All Allows the request only if both requirements are met (authentication AND access).

For the rest of this recipe, let's set an example scenario.

<Directory /home/www/site1/private>
  AuthUserFile /home/www/site1-passwd
  AuthType Basic
  AuthName MySite
  Require valid-user
</Directory>

With this configuration, your users will be required to authenticate as normal.

But let's say you want people from your LAN to have full access, without being prompted for a password. In this scenario we could use:

<Directory /home/www/site1/private>
  AuthUserFile /home/www/site1-passwd
  AuthType Basic
  AuthName MySite
  Require valid-user
  Order allow,deny
  Allow from 172.17.10
  Satisfy any
</Directory>

This will force everyone from the outside to authenticate, but those coming from the LAN IP range would not be required to do so. Apache will let them access the directory without authenticating. You can add other hostnames (local or remote) to the Allow directive to give them access to the directory as well. See the Apache Docs on Allow.

This will also work with a subdirectory in your protected directory. Let's say you have a subdirectory in private called noprotect that you want to allow everyone access to without being prompted for credentials. You could do this:

<Directory /home/www/site1/private/noprotect>
  Order allow,deny
  Allow from all
  Satisfy any
</Directory>

Finally, if you have a directory that is super-secret, you may want to restrict access to those on the LAN and demand a password:

<Directory /home/www/site1/super-secret>
  AuthUserFile /home/www/site1-passwd
  AuthType Basic
  AuthName MySite
  Require valid-user

  Order allow,deny
  Allow from 172.17.10
  Satisfy all
</Directory>

In this above example, the "Order allow,deny" line blocks access by default, the "Allow" directive allows the LAN, and the "Satisfy all" directive requires both LAN and password.

See the Apache Docs for further information on the Satisfy directive.

BypassAuthenticationOrAuthorizationRequirements (last edited 2009-10-16 12:18:37 by noodl)